Skip to main content
AllDevToolsHub
Back to all patterns

JSON String Literal

Extraction

Matches a single JSON-encoded string literal per RFC 8259.

/"(?:[^"\\\x00-\x1f]|\\["\\/bfnrt]|\\u[0-9a-fA-F]{4})*"/

How it works

Inside the quotes: any character except unescaped quote, backslash, or control character; or an allowed escape (\b \f \n \r \t \\ \/ \") ; or a \uXXXX Unicode escape.

Test Cases

Should Match

  • "hello"
  • "line\nbreak"
  • "unicode-\u00e9"

Should NOT Match

  • "raw break"
  • "unterminated
  • 'single-quoted'

Quick Summary

Matches a properly-escaped JSON string literal, useful when extracting strings from JSON-looking text.