Skip to main content
AllDevToolsHub
Back to all patterns

JSON Pointer (RFC 6901)

Validation

Validates a JSON Pointer string per RFC 6901.

/^(?:/(?:[^/~]|~0|~1)*)*$/

How it works

JSON Pointers reference values inside a JSON document. Tokens are slash-separated; ~ and / inside tokens are escaped as ~0 and ~1 respectively. The empty string is a valid pointer (referring to the root).

Test Cases

Should Match

  • /
  • /users/0/name
  • /a~1b/c~0d

Should NOT Match

  • users/0
  • /users/~
  • /a~2b

Quick Summary

Validates an RFC 6901 JSON Pointer. Tokens are slash-prefixed, with ~0 and ~1 escaping ~ and /.