Four shapes, because it means four things
"TXT to JSON" is asked for by people with quite different text in front of them, so there is no single right answer and the tool does not pretend there is.
Rows as objects is the common case: a spreadsheet
with a header row becomes a list of records with named keys, which
is what an API or a config loader usually expects.
Rows as arrays does the same without a header, for
data that is positional. Lines turns a simple list
into an array of values. Pairs reads
configuration-style key=value lines into one object.
Worked example: rows as objects
Paste this, with the header row kept:
name,role,years
Ada Lovelace,Engineer,12
"Smith, John",Editor,7
Grace Hopper,Admiral,40
With rows as objects and type conversion on, the output is:
[
{ "name": "Ada Lovelace", "role": "Engineer", "years": 12 },
{ "name": "Smith, John", "role": "Editor", "years": 7 },
{ "name": "Grace Hopper", "role": "Admiral", "years": 40 }
]
Notice two things. "Smith, John" stayed one field even
though it has a comma inside it, because the value was quoted in the
source — the parser reads quotes, it does not just split on every
comma. And years became a number in each record, not a
quoted string, because it looked like a plain integer.
Worked example: lines
Paste 007, 42, true and
Hello World on four lines and pick lines.
With type conversion on, the array is:
["007", 42, true, "Hello World"]
42 became a number and true became the JSON
boolean, but 007 stayed a quoted string — the leading
zero rule described below.
Worked example: pairs
Paste three settings lines and pick pairs:
host=localhost
port=8080
debug=true
The result is one object, not an array:
{ "host": "localhost", "port": 8080, "debug": true }
Where this fits
This is for the middle of a job rather than the end of one. You have a spreadsheet someone sent you and you need it as a request body; a list of values that has to become a JSON array; a block of settings copied out of a wiki page that should be a config object. Small, one-off conversions where writing a script would take longer than doing it by hand — except doing it by hand is where the quoting mistakes come from.
It is not a data pipeline. There is no schema, no validation against one, and no transformation beyond the type inference described above. If you are converting the same file shape repeatedly, a script is the right answer and this page is the thing you use to check what the script should produce.
Valid by construction, then checked anyway
The output is produced by the browser's own JSON serialiser rather than by joining strings together. That distinction matters: a converter that builds JSON by concatenation breaks the first time a value contains a quotation mark or a backslash, and it breaks by producing something that looks fine and will not parse.
Having built it correctly, the tool then parses it back to confirm, and the line under the output says "valid JSON" only when that check passed. Belt and braces on a thing that is easy to get quietly wrong.
Numbers, and the ones that must not be
With type conversion on, text that looks like a number becomes a
JSON number, and true, false and
null become their JSON equivalents. Everything else
stays a string.
Two things are deliberately excluded. A value with a leading zero —
007 — stays text, because a leading zero almost always
marks an identifier rather than a quantity, and turning an account
number into the number seven destroys it. Anything too large to
represent stays text as well, because the alternative is
Infinity, which is not valid JSON at all. Turn the
option off entirely if you want every value quoted.
Delimited input is parsed, not split
The two delimited modes use a real parser, so a value like
"Smith, John" stays one field instead of becoming two,
and a newline inside a quoted value is part of that value. The
delimiter is detected from your data, so semicolon and tab files
work without changing a setting.
Where a header cell is blank it becomes column1,
column2 and so on, because a JSON key cannot be empty.
Where two columns share a name the later one wins, since an object
cannot hold the same key twice — rename it in your source if both
matter.
Common mistakes
- Picking "rows as objects" for data with no header. The first line becomes the keys, so a data row used as a header turns one real record into a set of field names. Use rows as arrays when there is no header line.
-
Expecting
007to become7. It will not, on purpose — see the leading-zero rule below. - Two columns with the same header name. A JSON object cannot hold the same key twice, so the second column's value overwrites the first in every record. Rename one column in the source before pasting.
-
Forgetting the separator setting in pairs mode.
If your file uses
key: valuerather thankey=value, switch the pair separator to colon first, or every line is skipped as malformed.
Edge cases
A blank header cell becomes column1, column2
and so on, because a JSON key cannot be empty. A line in pairs mode
with no = (or :) is not guessed at — it is
skipped, and the count under the output tells you how many lines
were skipped so you notice. Blank lines are dropped by default in
every mode when "skip blank lines" is checked; turn it off if a
blank line is meaningful to you, for example as an empty array
entry. A number too big for JSON to represent exactly, or a value
that would otherwise become Infinity, is kept as text
instead of being silently rounded.
Where your data goes
Nowhere. Parsing and serialising both happen in your browser as you type, which is why the output appears instantly. This page has no upload endpoint, a file you drop is read on your own device, and nothing is logged or stored.
Related tools
Going the other way — turning JSON, or already-delimited data, back into plain text — is a job for CSV to TXT. If the destination is a spreadsheet rather than an API, TXT to Excel builds a workbook instead of an object. For a delimiter swap without touching the shape of the data, see CSV to TSV.