JSON

JSON.isRawJSON

Determines whether a value is an object returned by JSON.rawJSON

Syntax

JavaScript
JSON.isRawJSON(value)

Parameters

ParameterTypeDescription
valueanyThe value to check

Return Value

true if the value is a raw JSON object, false otherwise

Examples

Basic Usage
const raw = JSON.rawJSON('42');
console.log(JSON.isRawJSON(raw)); // true
console.log(JSON.isRawJSON(42)); // false
Practical Example
function customStringify(obj: Record<string, unknown>) {
  for (const [key, val] of Object.entries(obj)) {
    if (JSON.isRawJSON(val)) {
      console.log(`${key} is raw JSON`);
    }
  }
  return JSON.stringify(obj);
}
Advanced Usage
console.log(JSON.isRawJSON(null)); // false
console.log(JSON.isRawJSON({})); // false
console.log(JSON.isRawJSON(JSON.rawJSON('true'))); // true

Understanding JSON.isRawJSON

The JSON.isRawJSON method in JavaScript determines whether a value is an object returned by JSON.rawJSON. It belongs to the JSON object and is one of the most widely used methods for working with json values in modern JavaScript and TypeScript applications.

The method signature is JSON.isRawJSON(value). It accepts 1 parameter: value. When called, it returns true if the value is a raw json object, false otherwise. Understanding when and how to use isRawJSON() helps you write more expressive, readable code.

Common use cases for JSON.isRawJSON include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like json-rawjson, json-parse, json-stringify, enabling you to chain operations together for complex data manipulation pipelines.

Supported in Chrome 114+, Firefox 135+, and Node.js 22+. Safari support is pending.

Browser Compatibility

Supported in Chrome 114+, Firefox 135+, and Node.js 22+. Safari support is pending.

Related Methods

More JSON Methods

Other methods in the JSON object

Related Tools

More JSON Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.