TXT to JSON

Converts text to JSON: a list of lines into an array, name=value lines into an object. The reverse conversion runs on the same page.

Paste your text or open a file. A list of lines becomes an array, lines like name=value become an object, and line-by-line JSON is collected into a single array. Blank lines and spaces at the edges are left out of the result.

What stays a string

The phone number 0079161234567 is not written as a number: the leading zeros would be lost. A 20-digit account number also stays a string, because a number keeps only 15 significant digits and the rest turn into zeros. Uncheck the box if everything should stay a string.

Duplicate field names

An object in JSON cannot have two fields with the same name. A second "name" becomes "name_2" and does not overwrite the first one. Each line is split at the first separator, so an entry like time=12:30 and a link with an equals sign inside stay intact.

Back to text

Nesting is flattened into paths: customer.name=Anna, orders[0].total=15000. An empty object and an empty array are written as {} and [], otherwise the field would silently disappear from the text. A line break inside a value is written as \n, because otherwise it would split the line in two.

Rate this tool

Help us get better

Other tools