Free, browser-based utilities for everyday developer workflows

JSON Pointer escaping: slash and tilde examples

JSON Pointer (RFC 6901) uses / to separate path segments, so a literal slash inside a key must be written as ~1, and a literal tilde as ~0. Get the order wrong and your pointer silently points at the wrong place.

Open this example in JSON Patch & Pointer

Open the tool, then paste the sample input below. Everything runs locally in your browser.

Open this example in JSON Patch & Pointer →

The problem

Because / is the segment separator, a property name that itself contains a slash — like user/profile — cannot be written literally. RFC 6901 defines two escapes: ~1 for / and ~0 for ~.

The decode order matters: when reading a token you replace ~1 first and ~0 second; when encoding a key you escape ~ first (to ~0) and then / (to ~1).

Sample input

Document with awkward keys
{
  "user/profile": {
    "display~name": "Asha"
  }
}
Correct JSON Pointer
/user~1profile/display~0name

Expected output

Resolved value
"Asha"

user/profile becomes user~1profile and display~name becomes display~0name. The pointer resolves to the string Asha.

How to do it

  1. Identify property names that contain / or ~.
  2. Escape every ~ as ~0 first.
  3. Then escape every / as ~1.
  4. Join the escaped segments with / and prefix the whole pointer with /.
  5. Paste the document and pointer into JSON Patch & Pointer to confirm it resolves.

Common mistakes

  • Writing /user/profile when the real key is the single string user/profile.
  • Escaping / before ~, which double-mangles keys that contain both.
  • Using URL encoding like %2F instead of the JSON Pointer escape ~1.
  • Confusing JSON Pointer with JSONPath, which uses dots and brackets.

Related tools

Related guides

FAQ

How do I escape / in JSON Pointer?

Replace the literal slash inside a key with ~1. For example the key user/profile becomes the segment user~1profile.

How do I escape ~ in JSON Pointer?

Replace the literal tilde with ~0. The key display~name becomes display~0name.

Is %2F valid in JSON Pointer?

Not for the pointer itself. Percent-encoding is for URI fragment form in transport; the JSON Pointer escape for a slash inside a key is ~1, not %2F.

What is the difference between JSON Pointer and JSONPath?

JSON Pointer (RFC 6901) addresses exactly one location with slash-separated tokens. JSONPath is a query language with wildcards and filters that can match many nodes.

Why does my JSON Patch path not match the field?

Usually the key contains a / or ~ that was not escaped, or the path uses dotted JSONPath syntax. Escape with ~1 and ~0 and start the pointer with /.

Escaping is a pure string transform that runs locally in your browser. No data is sent to a server.

Explore more JSON and API contract tools

Schema validation, JSON Patch, JSON diff and JSONPath testing — grouped in one place.

View the JSON & API contract toolkit →