TXT to JSON Converter

Turn a TXT file or pasted text into valid JSON as you type — a spreadsheet into objects, a list into an array, or key=value lines into a single object. Checked for validity before you copy it.

TXT to JSON converter

Convert

What is your text?
Output
Supports: TXTCSVTSV

Nothing is uploaded. This tool runs entirely in your browser, so the file never leaves your device. There is no server to send it to, no copy kept anywhere, and it keeps working if you lose your connection after the page has loaded.

Accepts .txt .csv You get: JSON you can copy or download Free, no sign-up

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 007 to become 7. 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: value rather than key=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.

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.

Frequently asked questions

Can I convert a .txt file directly?

Yes. Drop a .txt file (or a .csv or .tsv) onto the box, or choose it with the file picker, and its contents are read in your browser and converted exactly as if you had pasted them. The file is not uploaded.

Which shape should I pick?

Rows as objects for a spreadsheet with a header row — that is the usual case and gives you a list of records with named keys. Rows as arrays if there is no header. Lines for a simple list of values. Pairs for configuration-style key=value lines.

Is the output guaranteed to be valid JSON?

Yes, twice over. It is produced by the browser's own serialiser rather than by joining strings together, so quotes and backslashes inside your data are escaped correctly by construction. It is then parsed back to confirm, and says so under the output.

What does "convert numbers and true/false" do?

It turns text that looks like a number into a JSON number, and true, false and null into their JSON equivalents. Everything else stays a string. Turn it off if you want every value quoted.

Why did my value 007 stay a string?

Deliberately. A leading zero almost always means an identifier — an account number, a product code, a phone extension — and turning it into the number 7 destroys it. Leading zeros, and anything too large to represent, stay as text.

Does it handle commas inside fields?

Yes. The delimited modes use a proper parser, so "Smith, John" stays one value rather than splitting into two. The delimiter itself is detected from your data, so semicolon and tab files work without changing anything.

What happens to a duplicate column name?

The later one wins, because a JSON object cannot have two keys with the same name. Rename the column in your source if both matter.

Can I get it on one line?

Yes — turn off pretty-printing. That is what you want when the JSON is going into a config file or a request body rather than being read by a person.

Is my data uploaded?

No. Everything runs in your browser as you type, and this page has no upload endpoint.

About this converter

The output is valid JSON, which is not the same as being the right JSON for whatever will consume it. Key names come from your header row and types are inferred from what the values look like, so check a record or two against what the receiving system expects before feeding it several thousand.

TXT to HTML

A .txt file or plain text into clean HTML, as you type.

Text Tools

CSV to TSV

CSV to TSV and back, with quoting handled properly.

Data Tools

CSV to TXT

CSV to plain text, with the delimiter under your control.

Data Tools

TXT to Excel

Delimited text into a real .xlsx workbook.

Data Tools

More in Text Tools All tools