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
- Paste your text. Enter it in the Input box, or load a .txt, .csv or .json file with Select file.
- 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.
- 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.
- 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:
| Mode | Input (each on its own line) | Output |
|---|---|---|
| Lines → JSON array | apple and banana | ["apple", "banana"] |
| Key:Value → JSON object | name: Ana and age: 31 | {"name": "Ana", "age": 31} |
| Delimiter rows → nested array | a,1 and b,2 | [["a", 1], ["b", 2]] |
| Lines under root key | apple 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.
| Character | Escaped 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: Anaandtags[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.