I have user.txt log file which have this data below and I want to convert it in json format.

{"user":"Demo Admin","user_id":"57c4718434243dc47d8b456c","org_id":"57c4718434243dc47d8b456b","superuser_id":null,"superuser_name":null,"application":"Trackier Webapp","method":"GET","ip":"","domain":"demo.trackier.com","url":"https:\/\/demo.trackier.com\/admin.html","created":"2022-09-08 06:19:18","@timestamp":"2022-09-08T06:19:18Z"}
{"user":"Demo Admin","user_id":"57c4718434243dc47d8b456c","org_id":"57c4718434243dc47d8b456b","superuser_id":null,"superuser_name":null,"application":"Trackier Webapp","method":"GET","ip":"","domain":"demo.trackier.com","url":"https:\/\/demo.trackier.com\/admin.html","created":"2022-09-08 06:19:35","@timestamp":"2022-09-08T06:19:35Z"}
  • 3
    but that's already a json format, isn't it? see in https://jsonformatter.curiousconcept.com/ Sep 8, 2022 at 7:38
  • 1
    But that's already a json format. Maybe you want to cat the output of user.txt in json format. If you want to achieve that, you can use the command jq, for example: jq < user.txt Sep 8, 2022 at 7:42
  • 2
    @αғsнιη More precisely, it is one json document per line, akin to jsonlines.org.
    – Hermann
    Sep 8, 2022 at 7:46
  • 1
    Consider updating your question to show what the data should look like in the new format.
    – Kusalananda
    Sep 8, 2022 at 7:51

1 Answer 1


Assuming you want to convert that file with one json per line to one json array, you could do:

sed '1s/^/[/;$s/$/]/;$!s/$/,/' < file.multijson > file.json

Which inserts [ at the start of the first line, ] at the end of the last line, and , at the end of all but the last line.

If you have jq, you can also do:

jq -s < file.multijson > file.json

(add -c to get a compact form), but beware it may reformat numbers (like change 1e1 or 10.0000000000000001 to 10) or strings (like change "\u00e9" to "é").

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .