Omnikit
DevFilesMoneyAll tools
Ctrl K
Dev toolsFile toolsMoney calculatorsAll tools
HomeDeveloper toolsString Escape & UnescapeJSON Escape

JSON Escape

dev

Escape quotes, backslashes and line breaks so text fits in a JSON string

Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 16 Oct 2026.

A JSON string cannot hold a raw double quote, a backslash or a line break: each must be written as \", \\ or \n, and other control characters as \u001f-style codes. Paste any text, a log line, an HTML snippet or a whole file, and get it escaped exactly as JSON.stringify would, ready to drop between quotes.

Next:
  • Regex Escape Escape text so a regex matches it literally in JavaScript, Python, PHP, Java, Go or .NET
  • HTML Entity Encoder & Decoder Encode &, <, > and quotes as HTML entities, or decode every named and numeric entity

How to escape a string for JSON

1

Paste the text into the Input pane.

2

Check that Escape and JSON are selected; the escaped text appears in the Output pane.

3

Turn on Add quotes if you want the result wrapped in double quotes, ready to use as a JSON value.

4

Click Copy and paste the result into your JSON.

How JSON Escape works

Turn on ASCII only to write accents and emoji as \u codes too.

Every language that puts text between quotes needs a way to include the quote itself, the backslash and characters you cannot type, such as a line break. That is escaping. The rules differ slightly per language, and a string escaped for one can be wrong in another, so pick the language first.

Escape. Paste text and the escaped version appears as you type. JSON output matches what JSON.stringify writes, character for character. Turn on ASCII only to write accents and emoji as escape codes too, for systems that cannot carry UTF-8. Add quotes wraps the result so it is a complete literal.

Unescape. Paste the inside of a string, or the whole literal with its quotes, and get the text back. Each language's own rules apply: JSON refuses \x41, JavaScript refuses old octal escapes as strict mode does, Python keeps unknown escapes such as \d as written, and Java accepts \uuuu0041. The first invalid sequence is reported with its position.

The rest of the article, and all 6 questions about String Escape & Unescape, are on the String Escape & Unescape page.

Frequently asked questions

How do I escape double quotes in JSON?

Put a backslash before each double quote inside a JSON string, so He said "hi" is written as "He said \"hi\"". The backslash itself must also be doubled, as \\. Single quotes need no escaping in JSON, because JSON strings are always wrapped in double quotes.

How do I put a new line in a JSON string?

Write \n where the line should break. JSON does not allow a raw line break inside a string, so a multi-line text must have every line break, and every tab, escaped as \n and \t. A Windows line ending becomes \r\n. Pasting a multi-line text here produces exactly that.

Why does my JSON have backslashes everywhere?

Backslashes everywhere usually mean the JSON was stored as a string inside other JSON, so its quotes became \" and its line breaks \n. Unescape it once with the JSON setting and you get the inner JSON back; if it still shows backslashes, it was escaped twice and needs a second pass.

What is the difference between escaping and encoding?

Escaping marks special characters inside one format so they are read literally, such as \" inside a JSON string. Encoding rewrites the whole text into another form, such as Base64 or percent-encoding for URLs. An escaped string is still readable; an encoded one usually is not. Use the URL Encoder or Base64 tool for those jobs.

Sources

  • RFC 8259, The JSON Data Interchange Format, section 7 Strings (IETF)Which characters JSON requires escaped and the escape forms
  • ECMA-262, ECMAScript Language Specification, String literalsJavaScript escapes, \u{...}, template literals and line continuations
  • Java Language Specification SE 21, 3.10.7 Escape SequencesJava escapes, octal and \s
  • The Python Language Reference, 2.4.1 String and Bytes literals, escape sequencesPython escapes, \x, \u and \U
  • RFC 4180, Common Format and MIME Type for CSV Files, section 2 (IETF)Quoting CSV fields and doubling quotes
  • PostgreSQL documentation, 4.1.2.1 String ConstantsA single quote inside an SQL string is written twice

Last verified 16 October 2026.

Rates and rules change; check the source before you rely on a figure.

Still stuck? Ask about String Escape & Unescape and anybody who knows can answer. No account needed.

More ways to use String Escape & Unescape

  • String Escape & UnescapeEscape text for a JSON, JavaScript, Java, Python, SQL or CSV string, or unescape it

Same job, other tools: Query String Parser – Split a URL query string into a table of decoded parameters · Base64 Decode – Turn Base64 back into text or a downloadable file · Base64 Encode – Turn text or a file into Base64 · TSV to JSON – Convert tab-separated values, such as a paste from Excel, into JSON · JSON to YAML – Turn JSON into clean, readable YAML for configs.

Related tools

All developer tools
Base64 Encode & DecodeText and files to Base64 and back, with URL-safe mode and image previewUnix Timestamp ConverterUnix timestamps to dates and dates to timestamps, in any time zoneJSON to TypeScriptGenerate TypeScript interfaces or types from a JSON sampleCSV to JSONConvert CSV to JSON and JSON to CSV, with a table previewYAML to JSONConvert YAML to JSON and JSON to YAML, with anchors resolvedURL Encoder / DecoderPercent-encode or decode text and URLs, and see every part of a linkColor ConverterHEX, RGB, HSL, HWB, OKLCH and CMYK in both directions, with a contrast checkNumber Base ConverterBinary, octal, decimal, hex and any base to 36, exact at any size, with two's complement
Was this tool helpful?
Omnikit

Small jobs, done in your browser. Free, fast and private. Files are never uploaded.

Files

  • Compress Image
  • Image to PDF
  • Merge PDF
  • Compress PDF
  • PDF to Word
  • Word to PDF

Dev

  • JSON Formatter & Validator
  • Base64 Encode & Decode
  • JWT Decoder, Verifier & Encoder
  • Password Generator
  • UUID Generator
  • Unix Timestamp Converter

Money

  • SIP Calculator
  • EMI Calculator
  • GST Calculator
  • FD Calculator
  • PPF Calculator
  • Lumpsum Calculator
GuidesQuestionsAboutHow we checkLaw library (beta)PrivacyTermsDisclosureContactMore: Exam practice (UGC NET Paper 1)Runs in your browser. Nothing is uploaded. © 2026 Omnikit (theomnikit.com)