How to Fix Chinese Garbled Text After JSON to CSV Conversion
Chinese garbled text after JSON to CSV conversion is usually caused by an encoding mismatch: the export writes using the system default encoding, but Excel parses UTF-8 bytes as GBK. The solution is to first confirm the export encoding is UTF-8, then make Excel recognize it correctly.
The easiest approach is to add a UTF-8 BOM (byte order mark) to the CSV. When Excel sees it, it will automatically open the file as UTF-8. If you are using a tool that runs locally in the browser, you can usually check this option in the export settings.
Why Garbled Text Appears
CSV itself is plain text and contains no encoding declaration. Whether its Chinese characters display correctly depends on whether the writing side and the reading side use the same encoding.
If the writing side saves as UTF-8 and the reading side decodes as GBK, you will get "锟斤拷" or a string of question marks. The reverse also causes garbled text.
There is another case where the data itself is fine, but Excel guesses the encoding wrong when you double-click to open it. Reading it with Notepad or code works normally. This is a display issue, not data corruption.
How to Fix Chinese Garbled Text After JSON to CSV Conversion
Troubleshoot in the following order. Most cases can be solved in the first two steps.
- Confirm the export encoding is UTF-8. Look for "Encoding" in the export options and select UTF-8. If only "UTF-8 with BOM" is available, choose that first.
- Add a BOM. If the export is UTF-8 without BOM, use a text editor to save as "UTF-8 with BOM", or have the tool export a version with BOM directly.
- Open using the import method instead. In Excel, go to "Data - From Text/CSV" and manually select UTF-8 as the encoding instead of double-clicking the file.
- Check the encoding of the original JSON. The JSON specification requires UTF-8, but some APIs return byte streams encoded in GBK. Confirm the source data encoding first, then decide how to convert.
- Confirm there are no leftover escapes in field values. When Chinese is written as Unicode escapes like
\u4e2d\u6587, it needs to be decoded before export, otherwise it will display as literal text.
After handling the encoding, if the CSV still displays abnormally, open the file with a hex viewer and check whether the first three bytes are EF BB BF. If so, the BOM has been written.
How to Perform JSON to CSV Conversion
The basic process has three steps: read JSON, flatten the structure, write CSV.
JSON allows nested objects and arrays, while CSV only has a two-dimensional table. So the first step is to expand nested levels into column names. For example, {"user":{"name":"Zhang San"}} becomes the column name user.name.
Common approaches are:
- Treat each object in the JSON array as a row.
- Iterate through all objects and collect all keys that appear as the header.
- Fill missing keys with empty strings to keep columns aligned.
- When values contain commas, quotes, or line breaks, wrap them in double quotes and escape internal quotes.
You can find tools that run locally in the browser at /tools; data is not uploaded to a server. For the specific tool page, see JSON to CSV Tool.
Differences Between JSON and CSV
Understanding the differences helps you judge what will be lost during conversion.
- Structure: JSON supports nested objects and arrays; CSV only supports flat two-dimensional tables.
- Types: JSON has strings, numbers, booleans, null, and other types; CSV is all text.
- Encoding: The JSON specification requires UTF-8; CSV has no mandatory requirement.
- Size: JSON is usually larger than equivalent CSV because it includes key names and brackets.
- Use cases: JSON is suitable for API transmission; CSV is suitable for table viewing and bulk import.
The cost of conversion is that nested information gets flattened. Array fields are generally serialized into JSON strings and placed into cells, or split into multiple rows.
Handling Large Files for JSON to CSV Conversion
When files exceed tens of megabytes, reading everything into memory at once can easily freeze the browser tab.
A more stable strategy is streaming: read chunk by chunk and write row by row. This way memory usage is only related to the size of a single row and does not grow with the file.
Also note a few points:
- Scan once first to collect all keys, avoiding column misalignment caused by new keys appearing later.
- Disable live preview when exporting large files to reduce rendering overhead.
- Export in batches into multiple CSVs; they are easier to open than one huge file.
- If browser memory is still tight, switch to command-line tools.
Tools that run locally in the browser are limited by tab memory when handling large files. This is determined by the environment, not a tool defect. When files are too large, it is recommended to switch to a local script.
API Debugging JSON to CSV Conversion
When debugging APIs, you often need to quickly convert returned JSON into a table to verify fields.
At this point, the focus is on preserving the original structure; do not rush to flatten it. First save the response as a .json file, confirm the encoding and integrity, then convert.
A few practical habits:
- Explicitly use UTF-8 when saving responses to avoid being rewritten midway.
- First check whether the top level is an object or an array. A single object must be wrapped in an array before conversion.
- Pay attention to pagination fields to avoid converting only one page of data.
- When field names contain dots or brackets, watch out for column name conflicts.
After conversion, compare column names against the API documentation to quickly find missing fields or naming changes.
Mobile JSON to CSV Conversion Without Installation
When handling JSON on a phone, installing an app is often more troublesome than using a web page.
Tools that run locally in the browser are also available on mobile. They do not require installing any application and do not rely on uploading data over the network. Just open the page, paste or select a file, and export.
Mobile limitations are mainly memory and the file picker. Very large files are not recommended for processing on a phone. After export, you can open them with spreadsheet apps. If garbled text appears, also check the encoding first.
Common Questions
What if it is still garbled after adding a BOM
First confirm that the BOM was actually written. Use a hex viewer to check whether the beginning is EF BB BF. If it has been written and it is still garbled, the problem is not the BOM but the source data encoding. Go back to the JSON source and confirm whether it is UTF-8.
It opens normally in Notepad but is garbled in Excel
This means the data is fine and Excel guessed the encoding wrong. Use "Data - From Text/CSV" to import and manually specify UTF-8 instead of double-clicking the file.
Chinese becomes something like \u4e2d\u6587
This is a Unicode escape sequence, not garbled text. It needs to be decoded before conversion, restoring the escapes to real characters, and then writing out the CSV.
Array fields come out as a string of JSON
This is normal. CSV has no array type, so arrays can only be serialized into strings and placed into cells. If you need to expand them, you must manually split them into multiple rows.
The number of rows increased after conversion
It is most likely that array fields were expanded into multiple rows. Check how arrays are handled in the conversion settings and choose either "serialize as string" or "expand into multiple rows".
Conclusion
Chinese garbled text can basically always be solved by unifying the encoding, preferably UTF-8 with BOM. The answer to how to fix Chinese garbled text after JSON to CSV conversion is ultimately to make the writing side and reading side use the same encoding and let Excel know which one to use. When choosing tools, prefer ones that run locally in the browser so data never leaves your machine, making debugging and conversion more reassuring.