Skip to content

Text to JSON Converter

Turn plain text into valid JSON: a list becomes an array, key: value lines become an object, and comma-separated rows become nested arrays. Paste JSON instead to flatten it back into text.

Drop a text or JSON file here

Or paste straight into Input below.

.txt, .json and .csv files. Read on your device.

Conversion options

Auto detect picks the direction. Output updates as you type.

Waiting for input
Ready. Paste text or JSON, or choose a file to begin.
StatusWaiting
Detected Input—
DirectionAuto
Input Size0
Output Size0
Rows / Items0

Input & Converted Output

Paste text or JSON on the left. The converted result appears on the right.

No action yet Line 1, Col 1

Input

Editable 0 chars
1
Ready for input No file loaded
Detection idle

Output

Result preview 0 chars
1
No output yet Ready to download
Type idle

Input Analysis

Inspect detected format, line count, objects, arrays, keys, and a compact structural preview before converting.

Run the tool or click Analyze Input to inspect the current content here.

Result Snapshot

See quick stats about the current output including direction, detected input type, mode, item count, and overall size.

Snapshot idle
Detected Input—
Text → JSON Mode—
JSON → Text Mode—
Indent—
Rows / Items0
Output Size0 B

Runs in your browser. Nothing you type, paste or open here is uploaded.

To convert text to JSON, paste one item per line into the Input box and leave Text → JSON Mode on Lines → JSON array. Each line becomes an array item, with quotes and backslashes escaped for you. For key: value lines choose Key:Value → JSON object. The JSON appears in Output as you type; select Download to save a .json file.

How to convert text to JSON

  1. Paste your text. Enter it in the Input box, or load a .txt, .csv or .json file with Select file.
  2. Choose a mode. Under Text → JSON Mode pick Lines → JSON array, Key:Value → JSON object, Delimiter rows → nested array or Lines under root key. Set a different separator in Delimiter / KV Separator if needed.
  3. Set the options. Trim lines, Ignore empty lines and Infer numbers / booleans / null are on by default. Choose a JSON Indent of 2 spaces, 4 spaces or Minified.
  4. Save the JSON. Output updates live. Select Copy output, or Download for a .json file.

Four ways to convert text to JSON

Each mode reads your text line by line. Pick the one that matches how your text is laid out:

ModeInput (each on its own line)Output
Lines → JSON arrayapple and banana["apple", "banana"]
Key:Value → JSON objectname: Ana and age: 31{"name": "Ana", "age": 31}
Delimiter rows → nested arraya,1 and b,2[["a", 1], ["b", 2]]
Lines under root keyapple and banana{"items": ["apple", "banana"]}

In Key:Value mode, each line is split at the first separator only, so a value like site: https://example.com keeps its own colon. Every line must contain the separator, and if a key repeats, the last value wins. For rows, the default delimiter is a comma; type \t in Delimiter / KV Separator to split tab-separated text pasted from a spreadsheet. Tick Force root wrapper to put any result inside {"data": ...}.

Numbers, booleans and null

With Infer numbers / booleans / null on, the values true and false become JSON booleans, null becomes null, and whole or decimal numbers such as 42 or -3.5 become numbers. Everything else stays a string. Values written as 1,000 or 1e5 stay strings too.

Codes that only look like numbers are protected: a value with a leading zero, such as the ZIP code 02134, stays a string, and so does a whole number too long to store exactly (more than about 15 digits), because JSON numbers in JavaScript are 64-bit floating point. Unticking the option keeps every value as a string, exactly as typed.

JSON escape string rules

JSON strings sit inside double quotes, so some characters must be escaped with a backslash. The converter does this automatically for every string it creates.

CharacterEscaped in JSON
Double quote\"
Backslash\\
Tab\t
Line break\n
Other control characters\u0000 to \u001f

So the line She said "hi" becomes "She said \"hi\"" in the array. Single quotes, slashes and non-English letters don't need escaping. Because every mode works one line at a time, a whole paragraph with line breaks isn't turned into one string with \n inside it; each line becomes its own item instead.

Convert JSON back to text

Paste valid JSON and Auto detect switches to JSON → Text. Four output styles are available under JSON → Text Mode:

  • Readable lines lists every value with its path, such as user.name: Ana and tags[0]: red.
  • Values only lists just the values, one per line.
  • Key:Value lines lists the top-level keys; nested objects are shown as JSON. The JSON must be an object, not an array.
  • Minified JSON text strips all whitespace into a single line.

If the JSON is invalid, you'll get an error instead of output. To find the broken bracket or comma, paste it into the JSON formatter. For spreadsheet-ready output from an array of objects, use JSON to CSV.

Frequently asked questions

How do I convert a list to a JSON array?

Paste the list with one item per line and keep the mode on Lines → JSON array. Each line becomes one item, and numbers and true or false are typed automatically.

Can I convert a string to JSON?

Yes. A single line in Lines → JSON array mode becomes a one-item array with the string correctly quoted and escaped. If your string is already JSON, the tool detects it and turns it into readable text instead.

How do I convert CSV text to JSON?

Choose Delimiter rows → nested array. Each row becomes an array of values split on commas, or on whatever separator you enter. The header row is treated as an ordinary row.

Why did my ZIP code or phone number lose a leading zero?

It shouldn't: values with a leading zero, such as 02134, are kept as strings even with Infer numbers / booleans / null on. A number without a leading zero, such as 5551234, still becomes a number, so untick that option to keep every value as a string.

Can I sort the keys?

Yes. Tick Sort object keys to order keys alphabetically, including keys inside nested objects.

Is my data uploaded?

No. The conversion runs in your browser, and files you load stay on your device.

Updated 11 October 2026Reviewed by the ToolzyLab teamHow we test our tools