String Format

Escape String for JSON Online

Escape quotes, tabs, newlines, and backslashes for JSON or JavaScript strings, then reverse common escape sequences when needed.

Quick answer

This tool escapes or unescapes text for JSON strings, JavaScript strings, and regex-safe output directly in the browser.

Use it when a copied payload contains quotes, tabs, backslashes, or newlines that should be preserved safely inside another string value.

Input Raw string
Output Escaped result
ModeEscape
PresetJSON
Output chars0

How to use

  1. Paste raw text or an escaped string into the input box.
  2. Choose Escape or Unescape, then pick the JSON, JavaScript, or Regex preset.
  3. Copy the converted result.

Common questions this page answers

  • How do I escape a string for JSON?
  • How do I unescape \n, \t, or backslashes?
  • How do I make copied text safe for a regex pattern?

Example input and output

Input

He said "hello"
Path: C:\temp

Output with JSON preset

He said \"hello\"\nPath: C:\\temp

FAQ

Does this tool send pasted text to a server?

No. The conversion runs in the browser and keeps your text on the device.

What escape sequences can unescape mode handle?

It handles common sequences such as \n, \t, \r, quotes, and backslashes.

When should I use the regex preset?

Use it when user text will be inserted into a regex pattern and special regex characters should be escaped first.

Ready.