Guide

Escape a string for JSON

Convert raw text with quotes, newlines, tabs, or backslashes into JSON-safe string content before pasting it into an API payload, config file, or fixture.

Raw input

Line "one"
Line two with tab

Escaped JSON string content

Line \"one\"\nLine two with tab

Steps

  1. Open Escape String for JSON Online.
  2. Paste the raw string.
  3. Keep the JSON string preset selected.
  4. Copy the escaped result and place it inside your JSON value.

Common reasons strings break JSON

  • Unescaped double quotes
  • Literal newline or tab characters
  • Backslashes copied from file paths or regexes

Related workflows

After escaping a string, developers often format the surrounding payload with JSON Formatter and Validator or URL encode it for transport.

FAQ

Do I need to escape single quotes for JSON?

No. JSON strings are delimited by double quotes, so single quotes usually do not need escaping unless another layer requires it.

Can I reverse the escaped result back into raw text?

Yes. The escape tool has an unescape mode for turning common escape sequences back into readable text.

Should I validate the final JSON too?

Yes. After escaping the string, run the full payload through the JSON formatter and validator to catch missing commas or broken braces.

Ready.