π€ JSON to Text Converter: Beautify, Minify, or Flatten JSON
By Shihab Mia Β· Updated 2026-08-04
This tool turns pasted JSON into readable text three ways. Beautify re-formats it with clean indentation, Minify strips every space onto one line, and Flatten to text lists each value as a plain "dot.path.key: value" line. Paste your JSON, pick a mode, and copy the result. If the JSON is broken, you get the exact parser error in red so you can fix it fast. Everything runs in your browser, so the JSON never leaves the page.
What is the JSON to Text Converter?
JSON (JavaScript Object Notation) is a text format for structured data, but the same data can be written in very different shapes. A minified API response is one dense line with no spaces, which is efficient for machines but painful to read. A beautified version adds line breaks and indentation so a human can follow the nesting. This converter moves your JSON between those shapes and, when you need something even plainer, collapses it into a flat list of key paths and values. Beautify and Minify are lossless, they only change the whitespace and never touch the underlying data.
Beautify works by parsing the text into a real object and then re-serialising it with a chosen indent. Because it parses first, it also acts as a validator: if the input is not valid JSON, it cannot be beautified and you see the parser message instead. The indent choice (2 spaces, 4 spaces, or a tab) is purely cosmetic. Two spaces is the most common default in config files and JavaScript projects, four spaces suits people who like more separation, and tabs let each viewer set their own width. The data itself is identical whichever you pick, this is the same idea as JSON.stringify(value, null, indent) in JavaScript or json.dumps(data, indent=2) in Python.
Minify does the opposite. It parses the JSON and re-serialises it with no spaces or line breaks at all, producing the most compact valid form. This is what you want before embedding JSON in a URL, a data attribute, or a request body, or when you are measuring or reducing payload size before it goes over a network. Minifying also normalises the formatting, so two files that differ only in whitespace become byte-for-byte identical, which is handy for comparing, hashing, or diffing two API responses to see if the actual data changed.
Flatten to text is the plain-text mode, and it is the one that genuinely turns JSON into text rather than just reformatting JSON as JSON. Instead of keeping the nested braces, it walks the whole structure and writes one line per leaf value, naming each value by the path used to reach it: object keys are joined with dots and array items are shown with their index in square brackets. So {"address":{"city":"London"}} becomes address.city: London. This is ideal for grep-style searching, for pasting values into a spreadsheet or a document, for feeding plain lines into a script, or for quickly reading a big config without mentally parsing the brackets. Empty objects and arrays are shown as {} and [] so nothing silently disappears from the output.
The same three transforms can be done in code if you are automating a pipeline rather than converting a one-off file. In JavaScript, JSON.parse followed by JSON.stringify covers beautify and minify, and a small recursive function covers flatten. In Python, json.loads and json.dumps do the same job, and Aspose and similar libraries can batch-convert JSON files to TXT on disk. This tool exists for the interactive case: paste, pick a mode, copy, without installing anything or writing a script for a single file.
When to use it
- Beautifying a minified API response so you can actually read the fields and nesting while debugging.
- Minifying a JSON config before pasting it into a URL, a data-* attribute, or a request body where size matters.
- Flattening a deep config file into a simple list of dot.path: value lines you can scan or grep.
- Turning JSON into plain text you can drop into a document, an email, a ticket, or a spreadsheet without the braces.
- Validating JSON on the fly, the red error message pinpoints where the parser gave up so you can fix a broken payload.
- Normalising two JSON snippets to the same formatting so a diff or a manual comparison only shows real data changes.
How to use the JSON to Text Converter
- Paste or type your JSON into the input box at the top.
- Choose a mode: Beautify, Minify, or Flatten to text.
- For Beautify, pick an indent of 2 spaces, 4 spaces, or a tab.
- Read the converted text in the result box, it updates as you type.
- Check the leaf value and character counts under the result if you need a quick size or field count.
- Click Copy to put the result on your clipboard, or Load sample to see an example.
Formula & method
Worked examples
Beautify a minified object with a 2 space indent. Input: {"name":"Ada","born":1815}
- The tool runs JSON.parse on the input, turning the text into a real object.
- Because parsing succeeds, the JSON is valid, no error is shown.
- It re-serialises with JSON.stringify(value, null, 2), adding line breaks and 2 space indentation.
- Each key goes on its own indented line inside the braces.
Result: A multi line block: {\n "name": "Ada",\n "born": 1815\n}
Flatten a nested object to text. Input: {"address":{"city":"London","zip":"SW1"},"active":true}
- The tool parses the input, then walks the structure leaf by leaf.
- For address.city it joins the two keys with a dot and outputs the value: address.city: London
- For address.zip it does the same: address.zip: SW1
- active is a top level boolean, so it outputs active: true
Result: Three lines: address.city: London / address.zip: SW1 / active: true
Minify a formatted array of objects for a URL parameter. Input: [ { "id": 1, "tag": "a" }, { "id": 2, "tag": "b" } ]
- The tool parses the array of two objects, both are valid, no error is shown.
- It re-serialises with JSON.stringify(value), no third argument, so no spaces or line breaks are added.
- Every key, colon, comma, and bracket is kept, only the whitespace between tokens is removed.
- The result is one dense line ready to URL-encode or paste into a request body.
Result: One line: [{"id":1,"tag":"a"},{"id":2,"tag":"b"}]
What each mode does to the same JSON
| Mode | What it changes | Best for |
|---|---|---|
| Beautify | Adds line breaks and indentation, data unchanged | Reading and debugging responses |
| Minify | Removes all whitespace onto one line | Smaller payloads, URLs, data attributes |
| Flatten to text | Replaces nesting with dot.path: value lines | Grep, spreadsheets, plain documents |
How values look after flattening
| JSON input | Flattened text output |
|---|---|
| {"a":1} | a: 1 |
| {"user":{"id":7}} | user.id: 7 |
| {"tags":["x","y"]} | tags[0]: x and tags[1]: y |
| {"note":null} | note: null |
| {"list":[]} | list: [] |
| {"active":false} | active: false |
Doing the same conversion in code
| Language | Beautify | Minify |
|---|---|---|
| JavaScript | JSON.stringify(value, null, 2) | JSON.stringify(value) |
| Python | json.dumps(data, indent=2) | json.dumps(data, separators=(",", ":")) |
| This tool | Beautify mode, pick 2, 4, or tab | Minify mode, one click |
Common mistakes to avoid
- Pasting JavaScript objects instead of JSON. JSON requires double quotes around every key and string, no trailing commas, and no comments. Object notation copied from JavaScript code (single quotes, unquoted keys, // comments) will fail to parse. Convert it to strict JSON first.
- Expecting Beautify to fix invalid JSON. Beautify parses the input before re-formatting, so it can only pretty print JSON that is already valid. If you see a red error, the input has a syntax problem such as a missing brace or an extra comma that must be fixed before formatting.
- Assuming minify changes the data. Minify only removes whitespace. The keys, values, and structure are identical, so the minified and beautified versions represent exactly the same data. Do not expect numbers to be rounded or keys to be dropped.
- Thinking flatten output is still JSON. Flatten to text produces plain text lines, not JSON. You cannot parse the result back into an object with a JSON parser. Use Beautify or Minify when you need output that is still valid JSON.
- Not noticing duplicate keys silently overwrite each other. JSON allows the same key to appear twice in one object, and JSON.parse keeps only the last value. If a flattened line looks wrong, check the raw input for a repeated key before assuming the tool made a mistake.
- Forgetting that flattened numbers and strings look identical. Flatten to text prints a number and a numeric-looking string the same way, for example both age: 30 and age: "30" become age: 30. If you need to tell them apart, check the original JSON or use Beautify instead.
Glossary
- JSON
- JavaScript Object Notation, a text format for representing structured data as objects, arrays, strings, numbers, booleans, and null.
- Beautify
- Reformatting JSON with line breaks and indentation so it is easy for a person to read. Also called pretty printing.
- Minify
- Reformatting JSON with no spaces or line breaks so it takes the fewest characters, useful for transport and storage.
- Flatten
- Collapsing a nested structure into a single level, here into one dot.path: value line per leaf value.
- Leaf value
- A value that is not itself an object or array, such as a string, number, boolean, or null. Flatten outputs one line per leaf.
- Indent
- The whitespace (2 spaces, 4 spaces, or a tab) placed before nested lines to show the depth of the structure.
- Dot path
- A key name built by joining nested object keys with dots, such as address.city, used by Flatten to text to label each value.
- Serialize / stringify
- Turning an in-memory object back into JSON text, done by JSON.stringify in JavaScript and json.dumps in Python.
Frequently asked questions
How do I convert JSON to text?
Paste your JSON into the input box and choose a mode. Beautify gives readable indented text, Minify gives one compact line, and Flatten to text gives plain dot.path: value lines. The result appears instantly and you can copy it with one click.
What is the difference between beautify and minify?
Both keep the data identical and only change whitespace. Beautify adds line breaks and indentation so people can read the structure, while Minify removes all spaces and line breaks to make the smallest possible one line version.
What does flatten to text do?
It walks the whole JSON structure and writes one line for every leaf value, naming each value by its path. Object keys are joined with dots and array items use their index, so {"a":{"b":1}} becomes a.b: 1. The output is plain text, not JSON.
Why do I get an invalid JSON error?
The tool tries to parse your input first, and shows the exact parser message if it fails. Common causes are single quotes instead of double quotes, unquoted keys, trailing commas, or a missing bracket. Fix the spot the message points to and convert again.
Is my JSON uploaded or stored anywhere?
No. All parsing and conversion happen in your browser with JavaScript, so your JSON never leaves the page and nothing is sent to a server. That makes it safe for private API keys, tokens, or config data.
Which indent should I choose when beautifying?
Two spaces is the most common default in JavaScript and config files, four spaces gives more visual separation, and a tab lets each viewer set their own width. The choice is cosmetic and does not change the data at all.
How do I save the result as a .txt file?
Click Copy, then paste the result into a plain text editor such as Notepad or TextEdit and save it with a .txt extension. The tool converts in your browser and does not currently offer a direct file download.
Can I convert a large JSON file, not just a small snippet?
Yes, paste the whole JSON text into the input box. There is no fixed size limit, though very large files (many megabytes) may feel slower in the browser than a small config or API response.
How do I convert JSON to text in Python or JavaScript instead of using a tool?
In JavaScript, JSON.parse the string then JSON.stringify(value, null, 2) to beautify or JSON.stringify(value) to minify. In Python, use json.loads then json.dumps(data, indent=2) or json.dumps(data, separators=(",", ":")) for the compact form. This tool does the same thing without writing code.
Why do numbers and quoted number-like strings look the same after flattening?
Flatten to text prints only the value, not its type, so 30 and "30" both appear as 30 on the line. Use Beautify if you need to see the quotes and confirm whether a value is a string or a number.
What happens to null and empty arrays or objects when flattening?
Null values print as note: null, empty arrays print as list: [], and empty objects print as settings: {}, so you can still see that the key exists even though it has no leaf values inside it.
Sources
- JSON.stringify() , MDN Web Docs
- JSON.parse() , MDN Web Docs
- Introducing JSON , JSON.org