# JSON\_VALID

## Syntax

```sql
JSON_VALID(value)
```

## Description

Indicates whether the given value is a valid JSON document or not. Returns `1` if valid, `0` if not, and `NULL` if the argument is `NULL`.

{% tabs %}
{% tab title="Current" %}
The `JSON_VALID` function is automatically used as a [CHECK constraint](https://mariadb.com/docs/server/sql-statements/data-definition/constraint#check-constraints) for the [JSON data type alias](https://mariadb.com/docs/server/reference/data-types/string-data-types/json) in order to ensure that a valid json document is inserted.
{% endtab %}

{% tab title="< 10.4.3" %}
The `JSON_VALID` function is **not** automatically used as a [CHECK constraint](https://mariadb.com/docs/server/sql-statements/data-definition/constraint#check-constraints) for the [JSON data type alias](https://mariadb.com/docs/server/reference/data-types/string-data-types/json).
{% endtab %}
{% endtabs %}

## Examples

```sql
SELECT JSON_VALID('{"id": 1, "name": "Monty"}');
+------------------------------------------+
| JSON_VALID('{"id": 1, "name": "Monty"}') |
+------------------------------------------+
|                                        1 |
+------------------------------------------+

SELECT JSON_VALID('{"id": 1, "name": "Monty", "oddfield"}');
+------------------------------------------------------+
| JSON_VALID('{"id": 1, "name": "Monty", "oddfield"}') |
+------------------------------------------------------+
|                                                    0 |
+------------------------------------------------------+
```

## See Also

* [JSON video tutorial](https://www.youtube.com/watch?v=sLE7jPETp8g) covering JSON\_VALID.

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_valid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
