JSON string escape
Useful when putting long text or an Arabic message into a JSON file or an API request by hand.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Enter text and ascii only (\uxxxx for non-ascii).
- The result appears straight away and updates as you edit.
- Copy the result, or copy a link that keeps the same values to share it.
How it is calculated
Quote becomes \", backslash \\, and control characters become \b, \f, \n, \r, \t or \u00xx, the same result as JSON.stringify. In ASCII mode every character above 126 becomes \uxxxx in UTF-16 units.
Example
Inputs: ASCII only (\uxxxx for non-ASCII) = no. Result: Escaped string content: السطر الأول\nقال \"مرحبا\" في C:\\temp.
السطر الأول قال "مرحبا" في C:\temp
السطر الأول\nقال \"مرحبا\" في C:\\temp
Limits and caveats
- Forward slash / is not escaped because JSON does not require it.
- This escapes one string; to format a whole JSON document use a JSON formatter.
Questions about this tool
Do I need to turn Arabic into \u codes in JSON?
No. UTF-8 JSON accepts Arabic directly; the ASCII option only helps older systems.
Why do line breaks become \n?
JSON does not allow a raw line break inside a string, so it must be written \n.
Is the output the same as JSON.stringify?
Yes in normal mode; the same rules apply, including escaping lone surrogates.
