isJSON es-toolkit
Checks if a value is a valid JSON string.
Usage
isJSON(value)
Use isJSON when you want to check if a string is a valid JSON format. This function verifies if it can be parsed with JSON.parse(). According to JSON specifications, strings representing objects, arrays, strings, numbers, booleans, and null are all valid.
All non-string values return false:
Useful for API response or user input validation:
Accurately detects complex JSON structures:
Parameters
valueunknownrequired
The value to check if it's a valid JSON string.
Returns
Returns true if the value is a valid JSON string, false otherwise.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.