DevTools Surf logoDevTools Surf
AI / Modern DevAnimation / CSSAPI / Config
Sign in
DevTools Surf logoDevTools Surf
AI / Modern DevAnimation / CSSAPI / Config
Sign in
HomeJSONJSON Escape String

About JSON Escape String

JSON Escape String preview - JSON tool

Escape any text as a JSON-safe string with \n \t \uXXXX handling. Part of the DevTools Surf developer suite. Browse more tools in the JSON collection.

Use Cases

  • Paste a code snippet as a JSON value for API payloads
  • Embed multiline text in config files without hand-escaping
  • Convert localized strings containing quotes into JSON
  • Prepare multiline SQL snippets for a JSON config file

Tips

  • Escapes newlines, tabs, quotes, backslashes, and control chars
  • Produces a valid JSON string literal you can paste into any JSON value
  • Non-ASCII characters are also escaped to \uXXXX for maximum safety

Fun Facts

  • JSON.stringify() handles ~18 different escape sequences, but only five (\" \\ \n \r \t) are common.
  • JSON requires forward slashes to be optionally escapable (\/) — a quirk inherited from its use inside <script> tags where </script> would break HTML parsing.
  • The U+2028 (line separator) and U+2029 (paragraph separator) characters are valid in JSON strings but invalid in JavaScript — a mismatch that wasn't fixed until ES2019.

FAQ

What's the difference between escape and stringify?
Escape takes raw text (a code snippet, a shell command) and returns JSON-safe string literal content. Stringify takes a JSON value and wraps the whole thing in a string.
Are unicode characters escaped?
By default yes — \uXXXX sequences are emitted so the output works in ASCII-only contexts (cURL headers, shell scripts). Toggle 'ASCII-safe' off for raw UTF-8.
Does it escape newlines and tabs?
Yes — \n, \t, \r, and form feed become their escape sequences. Null bytes become \u0000.
Is the output ready to paste into a JSON file?
Yes, between a pair of double quotes. The tool only returns the escaped contents — add your own `"..."` wrapper.

Related JSON Tools

JSON FormatterJSON ValidatorJSON ViewerJSON StringifyJSON PatchJSON DiffJSONPath TesterJSON Sort Keys
New · Flagshipsimple REST client

REST Handler — Collections, env vars, history, cURL converter

Send requests, save collections (nested), swap environments, and convert between cURL / Collection JSON / REST Handler YAML.

Open

Popular tools

The most-used tools on DevToolsSurf, one click away.

Encoding & crypto

  • Base64 Encode
  • Base64 Decode
  • URL Encoder
  • URL Decoder
  • Hash Generator
  • JWT Decoder
  • JWT Encoder
  • UUID Generator
  • ULID Generator
  • Password Generator
  • Bcrypt Hash Tester

Converters

  • CSV to JSON
  • JSON to CSV
  • XML to JSON
  • JSON to XML
  • HTML → Markdown
  • HTML → React JSX
  • cURL to Code
  • Collection JSON → cURL
  • Swagger to Collection JSON
  • JSON → Go Struct
  • JSON → TypeScript Types

JSON & YAML

  • JSON Formatter
  • JSON Validator
  • JSON Viewer
  • JSON Minifier
  • JSON Diff
  • JSONPath Tester
  • YAML Formatter
  • YAML to JSON
  • JSON to YAML

Text & regex

  • Regex Tester
  • Text Diff
  • Case Converter
  • Word Counter
  • Markdown Preview
  • Slug Generator
  • Lorem Ipsum Generator
  • Markdown → PDF

CSS & color

  • CSS Beautifier
  • Minify CSS
  • Color Converter
  • Gradient Generator
  • Contrast Checker
  • Color Palette Generator
  • Flexbox Playground
  • Tailwind → CSS

Generators

  • QR Code Generator
  • Mock Data Generator
  • Favicon Generator
  • .gitignore Builder
  • README.md Generator
  • Dockerfile Generator
  • Sitemap Generator

API & networking

  • REST Handler
  • HTTP Header Analyzer
  • IP Address Lookup
  • CIDR Calculator
  • User-Agent Parser
  • HTTP Status Reference
  • OpenAPI Viewer

Date & time

  • Timestamp Converter
  • Timezone Converter
  • Cron Expression Parser
  • Duration Calculator
  • Age Calculator
  • Date Format Converter

Images

  • Image Converter
  • Image Resizer (Batch)
  • SVG Optimizer
  • Base64 ↔ Image
  • WebP ↔ AVIF Converter
  • Image Compressor

PDF tools

  • PDF Merger
  • PDF Splitter
  • PDF Compressor
  • Markdown → PDF
  • EPUB → PDF
  • MOBI / AZW → PDF
  • DOCX → PDF
  • HTML → PDF

Resources

  • Community feed
  • Themes marketplace
  • Pricing & credits
  • Privacy policy
  • Terms of service
  • Sitemap
  • robots.txt

Your account

  • Sign in
  • Dashboard
  • Run history
  • My profile
  • Settings
DevTools Surf logo
DevTools Surf919+ tools

Fast · privacy-first · client-side · © 2026

Home·Feed·ThemesPricing·Sign inPrivacy·Sitemap Feedback