JSON Stringify
Convert a JSON value into an escaped string literal you can drop straight into code or into another JSON field.
Input
JSON- characters
- 0
- lines
- 0
- size
- 0 B
Options
About this tool
Sometimes JSON needs to live inside a string: as a fixture in a test, as a value in another JSON document, or as a literal in source code. Stringifying wraps the document in quotes and escapes the inner quotes and control characters so it stays intact.
The tool parses your JSON first, so the string it produces always decodes back to the original value. You can choose to embed the compact form or keep the indentation inside the string.
How to use this tool
Paste the JSON you want to embed, or upload a file.
Decide whether to keep indentation inside the resulting string.
Press Stringify to produce the escaped string literal.
Copy the literal into your code, fixture or JSON field.
Key features
- Produces a valid, double-quoted JSON string literal
- Optionally preserves indentation inside the string
- Reversible with JSON Unstringify
- Validates the input before encoding
- No network request with your data
Example
Input — JSON
{"id":42,"name":"Ada"}Output — String
"{\"id\":42,\"name\":\"Ada\"}"Good to know
- The input must be valid JSON. To stringify arbitrary text instead, use JSON Escape.
- Very large documents grow further once escaped, since every quote gains a backslash.
Frequently asked questions
What is the difference from JSON Escape?
Stringify wraps a whole JSON value in quotes and escapes it. Escape works on any raw text and returns the escaped fragment without the surrounding quotes.
Can I get the original JSON back?
Yes. The JSON Unstringify tool parses the string literal and returns the original document.
Is my input uploaded?
No. Encoding happens in your browser.
Further reading
JSON escape characters — Eight escape sequences plus \uXXXX. Everything else after a backslash is a syntax error.
Your data stays on your device
Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.
Related tools
- JSON UnstringifyJSON ToolsTurn an escaped JSON string literal back into a real JSON document.StringJSON
- JSON EscapeJSON ToolsEscape any text so it can sit safely inside a JSON string.TextText
- JSON FormatterJSON ToolsPretty-print messy JSON with your choice of indentation and optional key sorting.JSONJSON
- JSON MinifierJSON ToolsStrip whitespace from JSON and see exactly how many bytes you saved.JSONJSON
- JSON to One LineJSON ToolsCollapse a multi-line JSON document onto a single compact line.JSONJSON
- JSON ParserJSON ToolsParse JSON, confirm it is valid, and see it as clean indented output.JSONJSON