JSON Stringify
Convert a JSON value into an escaped string literal you can drop straight into code or into another JSON field.
Your data stays on your device
Input — JSON
- characters
- 0
- lines
- 0
- size
- 0 B
Output — JSON string literal
- 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.
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.