Turn any text into a valid JSON string, with quotes, backslashes, line breaks and control characters escaped, the same as JSON.stringify. Paste JSON to stringify it: it's compacted first (strings and numbers stay exactly as written) and comes out as one string you can put in code, a test, an environment variable or another JSON document. Or go the other way: unescape a JSON string back into plain text. When the string holds JSON, such as {\"id\":1} from a log line, it comes back indented and coloured.
How to use it
- Choose Escape or Unescape.
- Paste the text, the JSON to stringify, or the JSON string to unescape.
- Copy the result. For JSON you can untick "Compact JSON first" to keep its line breaks.
Private, local processing
This tool runs in your browser: nothing you paste is uploaded, and nothing is kept after you leave. Already loaded features keep working if your connection drops. Loading another tool or jq for the first time needs a connection. When one tool isn't enough, GigaJSON opens your data with a tree, a table, JSONPath/JMESPath/jq queries, transforms, diff and history.
What JSON escapes
Inside a JSON string, these characters can't appear as they are. This is what the tool (and JSON.stringify) writes for each:
| Character | Escaped |
|---|---|
| Double quote | \" |
| Backslash | \\ |
| Line break (LF) | \n |
| Carriage return (CR) | \r |
| Tab | \t |
| Backspace, form feed | \b, \f |
| Other control characters (U+0000 to U+001F) | \u0001 and so on |
| /, é, emoji and other Unicode | Unchanged |
To put JSON inside JSON, escape it: {"id":1} becomes "{\"id\":1}". That's how a JSON payload ends up in a log line, a message queue or an environment variable. Unescape reverses it.
Stringify JSON in code
The same result as this page, in JavaScript and Python:
| Language | Code | Result for {"id": 1} |
|---|---|---|
| JavaScript, JSON text | JSON.stringify(obj) | {"id":1} |
| JavaScript, as a string | JSON.stringify(JSON.stringify(obj)) | "{\"id\":1}" |
| Python, JSON text | json.dumps(obj) | {"id": 1}, with spaces |
| Python, as a compact string | json.dumps(json.dumps(obj, separators=(",", ":"))) | "{\"id\":1}" |
Parsing a number in code can round it: 12345678901234567890 becomes 12345678901234567000 in JavaScript. This page never parses your numbers, so they stay as you pasted them.
Questions
How do I stringify JSON online?
Paste the JSON with Escape selected. It is compacted to one line and escaped, so {"id": 1} becomes "{\"id\":1}". Untick "Compact JSON first" to keep the indentation, written as \n.
What is the difference between JSON.stringify and escaping?
JSON.stringify(obj) turns an object into JSON text: {"id":1}. Escaping turns text into a JSON string literal, quotes and all. Stringifying JSON so it fits inside a string is both: JSON.stringify(JSON.stringify(obj)), which gives "{\"id\":1}". That is what this page does with JSON input.
What gets escaped?
Double quotes, backslashes, line breaks, tabs and other control characters. It's the same as what JSON.stringify does.
How do I unescape JSON that is inside a string?
Switch to Unescape and paste the string, quotes included, such as "{\"id\":1}". The result is the JSON, indented. Numbers with 16 or more digits are left exactly as written instead of being reformatted, so no digits are lost.
Does / need to be escaped in JSON?
No. JSON allows \/ but doesn't require it, so this tool leaves / as it is. Both forms read back the same.
How do I escape a string in JavaScript or Python?
JavaScript: JSON.stringify(text). Python: json.dumps(text), which also turns every non-ASCII character into \u escapes (é becomes \u00e9) unless you pass ensure_ascii=False. This tool keeps é as it is, like JSON.stringify.
Why does my JSON show \n instead of line breaks?
The text was escaped twice: a JSON string was stored inside another JSON string. Unescape it once here to get the inner text back.
Unescape says the input is invalid
Unescape expects one JSON string, with or without the quotes around it, e.g. "line one\nline two".
All tools
- JSON FormatterIndent with 2 or 4 spaces, sort keys
- JSON ValidatorLine and column of the first error
- JSON MinifierRemove whitespace, see the bytes saved
- JSON RepairFixes quotes, commas, comments, AI output
- JSON Schema GeneratorA JSON Schema from examples
- JSON Schema ValidatorCheck JSON against a schema
- JSON Token CounterCount tokens, select data, compare JSON and TOON
- JSON EditorTree and code editing, undo and history
- Large JSON ViewerTree, table and search for huge files
- JSON Lines ViewerJSONL and NDJSON logs as a table
- JSON Log ViewerCount and filter JSON Lines logs
- Large CSV ViewerCSV files too big for Excel, up to 1 GB
- JSON VisualizerThe data as a graph, PNG and SVG export
- JSON DiffChanges between two documents
- JSON Path FinderClick a value, copy its path
- JSONPath TesterJSONPath, JMESPath and jq, live
- JMESPath PlaygroundJMESPath, for AWS CLI queries too
- jq PlaygroundReal jq in your browser
- JSON to CSVNested objects become dotted columns
- JSON to ExcelAn .xlsx sheet, numbers kept as numbers
- CSV to JSONDelimiters detected, 007 stays 007
- JSON to XML@keys become attributes
- XML to JSONRSS feeds, sitemaps, SOAP responses
- JSON to YAMLReadable YAML, ambiguous strings quoted
- YAML to JSONAnchors and multiple documents
- JSON Lines to JSONNDJSON or JSONL into one array
- JSON to JSON LinesA JSON array as one record per line
- JSON to TOONConvert JSON to TOON, with token counts
- JSON to MermaidA flowchart or class diagram, drawn
- JSON SplitterCut a big file into parts, or sample it
- JSON to TypeScriptInterfaces inferred from your data
- JSON to GoGo structs with json tags
- JSON to RustRust structs that derive serde's Serialize and Deserialize
- JSON to PythonPython dataclasses with type hints
- JSON to JavaJava classes with getters and setters
- JSON to C#C# classes with System.Text.Json attributes
- JSON to KotlinKotlin data classes
- JSON to SwiftSwift structs that conform to Codable, with CodingKeys
- JSON to DartDart classes with fromJson and toJson
- JSON to ZodZod schemas with TypeScript types inferred from them
- JWT DecoderHeader, payload and expiry, locally
- JSON EscapeText to a JSON string and back
- Sample JSON FilesDownload test JSON, 100 KB to 1 GB
- Sample JSON Lines FilesDownload test NDJSON, one record per line
- Sample CSV FilesDownload test CSV, 100 KB to 1 GB
- Sample XML FilesDownload test XML, 100 KB to 1 GB
- Sample GeoJSON FilesPoints, lines and polygons, up to 1 GB
- Sample Nested JSONRecords 8 levels deep, up to 1 GB
- Sample Unicode JSON13 scripts, emoji and escapes
- Sample API ResponsesJSON:API, HAL, GraphQL, pages, errors
- Large JSON File GeneratorTest data from 100 KB to 1 GB