Python json.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig)
JSON file saved by Excel/Windows starts with `\xef\xbb\xbf` byte order mark.
Runs locally in browser
Free · No login
Independently Verified 2026-11-25
v4.1.0
Identifier: Python json.JSONDecodeError
Platform: Python
Common Root Causes:
- JSON file saved by Excel/Windows starts with `\xef\xbb\xbf` byte order mark.
Interactive Diagnostic Checklist
Verified Solutions:
- Open the file with `encoding="utf-8-sig"` so Python strips any leading BOM cleanly.
Safe Diagnostic Command:
head -c 4 <file.json> | od -tx1
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.
Technical Explanation
JSON file saved by Excel/Windows starts with `\xef\xbb\xbf` byte order mark. Recommended diagnostic: `head -c 4 <file.json> | od -tx1`. Remediation: Open the file with `encoding="utf-8-sig"` so Python strips any leading BOM cleanly.
Worked Examples
- Run `head -c 4 <file.json> | od -tx1` to verify root cause before applying the remediation.
Limitations & Assumptions
- Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.
Source References & Verification
Resource ID: err-py-json-decode-error-bom · Independently verified: 2026-11-25