In JavaScript, JSON.isRawJSON() answers one question: was this value made with JSON.rawJSON()? It returns true or false.
Use it in helpers that accept mixed data. If the value is raw, pass it to JSON.stringify() as-is. If it is not, treat it as a normal value. Learn how to create raw values on the JSON.rawJSON() page.
Syntax
Pass any value. The method only returns true for raw JSON values.
// ECMAScript 2024 (ES2024)
JSON.isRawJSON(value)
// value : any JavaScript value
// returns : true if value is a raw JSON value, otherwise false
Parameters
Parameter
Description
value
Required. Any value you want to test.
Return Value
Return Value
Description
true
The value was created with JSON.rawJSON().
false
The value is not a raw JSON value.
JavaScript Examples
Example 1 — Basic JSON.isRawJSON()
Compare a raw value with a normal string.
JavaScript
if (typeof JSON.isRawJSON !== "function") {
console.log("JSON.isRawJSON is not supported here.");
} else {
const raw = JSON.rawJSON("42");
const text = "42";
console.log(JSON.isRawJSON(raw));
console.log(JSON.isRawJSON(text));
}
{"body":{"ok":true}}
{"body":{"ok":true}}
First body is raw: true
Second body is raw: false
How It Works
Both payloads stringify to the same shape.
isRawJSON still tells them apart before stringify.
Use that check when a helper must handle both kinds of input.
Compatibility
Browser & Runtime Support
JSON.isRawJSON() is part of ES2024, together with JSON.rawJSON(). Feature-detect before use.
✓ ES2024 · Newer API
JSON.isRawJSON()
Available in recent Chrome, Edge, Firefox, Safari, and Node.js versions that implement JSON raw values. Older engines do not have it.
ES2024Standard since
Google Chrome114+ · Desktop & Mobile
Full support
Microsoft Edge114+ · Chromium
Full support
Mozilla Firefox126+ · Desktop & Mobile
Full support
Apple Safari17.4+ · macOS & iOS
Full support
Opera100+ · Chromium based
Full support
Samsung InternetRecent versions · Android
Varies
Android WebView114+ · Chromium based
Supported
Node.js21+ · Server runtime
Supported
DenoRecent versions · JavaScript runtime
Supported
BunRecent versions · JavaScript runtime
Supported
Internet ExplorerNo native support
Not supported
JSON.isRawJSON()Growing
Bottom line: Feature-detect both JSON.isRawJSON and JSON.rawJSON. For everyday work, JSON.parse() and JSON.stringify() are enough.
Frequently Asked Questions
It returns true when the value was created with JSON.rawJSON(), and false for every other value: strings, numbers, objects, null, and so on.
Helpers and libraries can treat raw values differently: pass them through to stringify, or reject them if the API expects a normal object. The check keeps that logic clear.
Always a boolean: true or false. It does not throw for normal inputs.
No. Only values created by JSON.rawJSON() are raw. A look-alike object still returns false.
No. It arrives with JSON.rawJSON() in ES2024. Feature-detect both methods before you use them.
Use typeof JSON.isRawJSON === "function". If the method is missing, skip raw-JSON paths and use normal stringify instead.