Common SQL Errors

MySQL Error 3144: ER_INVALID_JSON_CHARSET - How to Fix and Prevent

Galaxy Team
August 8, 2025

MySQL raises ER_INVALID_JSON_CHARSET when a JSON value is built from a string that is not encoded in UTF8, UTF16, or UTF32.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 3144 (ER_INVALID_JSON_CHARSET)?

MySQL error ER_INVALID_JSON_CHARSET happens when you try to insert or build JSON from text stored in a non-Unicode character set like latin1. Convert the input or column to utf8mb4, then re-run the statement to clear the error.

Error Highlights

Typical Error Message

ER_INVALID_JSON_CHARSET

Error Type

Data Type Error

Language

MySQL

Symbol

SET '%s'. ER_INVALID_JSON_CHARSET was added in 5.7.8.

Error Code

3144

SQL State

22032

Explanation

Table of Contents

What is MySQL error 3144 (ER_INVALID_JSON_CHARSET)?

Error 3144 is triggered when MySQL attempts to create or parse a JSON document from a string that is encoded with a character set other than UTF8, UTF16, or UTF32. The server refuses the operation to guarantee valid JSON storage.

When does it occur?

The error appears during INSERT, UPDATE, SELECT JSON_ functions, or CAST operations if the input string, column, or literal uses a non-Unicode charset such as latin1, cp1252, or ascii while sql_mode allows strict JSON validation.

Why is it important to fix?

Leaving the issue unresolved blocks data writes, breaks API responses, and can hide downstream bugs. Correcting the charset ensures consistent JSON encoding, enables binary JSON storage efficiency, and prevents silent data corruption.

What Causes This Error?

MySQL 5.7.8+ enforces that JSON text must be Unicode. Any attempt to feed non-Unicode bytes into JSON parsing raises ER_INVALID_JSON_CHARSET. Typical triggers include legacy tables created with latin1, improper client_encoding settings, or imported CSV files.

How to Fix ER_INVALID_JSON_CHARSET

Fixes involve converting offending columns or literals to utf8mb4, altering table defaults, and ensuring the client session uses utf8mb4. Always back up data before altering character sets.

Common Scenarios and Solutions

Applications that store JSON blobs in TEXT columns often fail after an upgrade to 5.7.8+. Bulk ETL jobs may load latin1 files, causing this error mid-transaction. Adjust the LOAD DATA statement or set character_set_connection.

Best Practices to Avoid This Error

Use utf8mb4 as the default schema charset, validate client encodings, and store JSON in native JSON columns defined as utf8mb4. Add test cases that confirm JSON functions run without charset errors.

Related Errors and Solutions

Similar issues include 3140 (ER_INVALID_JSON_TEXT) for malformed JSON and 3143 (ER_INVALID_JSON_PATH_CHARSET) for path expressions. Converting data to utf8mb4 typically resolves these as well.

Common Causes

Non-Unicode column charset

Columns defined as latin1, ascii, or other non-Unicode sets store the string, then MySQL rejects JSON conversion.

Client connection charset mismatch

If character_set_client or character_set_connection is latin1, literals are treated as latin1 even if the bytes are UTF8.

Imported files with legacy encoding

LOAD DATA or ETL scripts may import latin1 files directly into JSON columns without explicit character set handling.

Implicit cast in JSON functions

Calling JSON_EXTRACT on a non-JSON TEXT column forces an internal cast that fails when the data uses latin1.

Related Errors

Error 3140 ER_INVALID_JSON_TEXT

Raised when the JSON text is syntactically invalid, not just wrongly encoded.

Error 3143 ER_INVALID_JSON_PATH_CHARSET

Occurs if the JSON path string is in a non-Unicode charset.

Error 3141 ER_INVALID_JSON_PATH_WILDCARD

Triggered by wildcard misuse in JSON path expressions.

FAQs

How do I check my column's character set?

Run SHOW FULL COLUMNS FROM table_name to see Collation for each column.

Can I disable the strict JSON charset check?

No. MySQL always enforces Unicode for JSON values starting from 5.7.8.

Is utf8 sufficient or should I use utf8mb4?

Use utf8mb4 because utf8 in MySQL is limited to three bytes and does not cover all Unicode code points.

How does Galaxy help?

Galaxy's SQL editor highlights column charsets, suggests utf8mb4 conversions, and lets you run the ALTER TABLE commands directly with AI-generated patches.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo