Convert JSON to HEX
Max file size 100mb.
JSON vs HEX Format Comparison
| Aspect | JSON (Source Format) | HEX (Target Format) |
|---|---|---|
| Format Overview |
JSON
JavaScript Object Notation
Lightweight data interchange format that is easy for humans to read and write and easy for machines to parse and generate. Based on a subset of JavaScript, JSON has become the universal standard for web APIs, configuration files, and data storage. Data Format Universal Standard |
HEX
Hexadecimal Encoding
A byte-level representation that encodes each byte of data as two hexadecimal digits (0-9, A-F). Used extensively in debugging, firmware development, binary file analysis, network packet inspection, and any scenario where you need to examine raw data at the byte level. Encoding Binary Analysis |
| Technical Specifications |
Standard: RFC 8259 / ECMA-404
Encoding: UTF-8 (mandatory) Format: Text-based with strict syntax Data Types: String, Number, Boolean, Array, Object, null Extension: .json |
Representation: Base-16 (digits 0-9 and letters A-F)
Byte Encoding: Each byte = 2 hex characters (00-FF) Format: Hex dump with optional ASCII sidebar Variants: Intel HEX, Motorola S-record, raw hex dump Extensions: .hex, .ihex, .h |
| Syntax Examples |
JSON uses braces and brackets: {
"name": "My Project",
"version": "2.0",
"features": ["fast", "free"],
"database": {
"host": "localhost",
"port": 5432
}
}
|
HEX encodes each byte as two hex digits: 7B 0A 20 20 22 6E 61 6D |{. "nam|
65 22 3A 20 22 4D 79 20 |e": "My |
50 72 6F 6A 65 63 74 22 |Project"|
2C 0A 20 20 22 76 65 72 |,. "ver|
73 69 6F 6E 22 3A 20 22 |sion": "|
32 2E 30 22 0A 7D |2.0".} |
|
| Content Support |
|
|
| Advantages |
|
|
| Disadvantages |
|
|
| Common Uses |
|
|
| Best For |
|
|
| Version History |
Introduced: 2001 (Douglas Crockford)
Standard: RFC 8259 (2017), ECMA-404 (2013) Status: Universal standard Evolution: JS subset → RFC 4627 → RFC 7159 → RFC 8259 |
Origins: 1950s-60s (early computing, IBM mainframes)
Intel HEX: 1973 (Intellec 8 development system) Status: Fundamental computing representation Evolution: Octal dumps → hex dumps → Intel HEX → modern hex editors |
| Software Support |
JavaScript: JSON.parse() / JSON.stringify() (built-in)
Python: json module (built-in) Databases: MongoDB, PostgreSQL JSONB, MySQL JSON Other: Every modern language has native JSON support |
Editors: HxD, Hex Fiend, xxd, hexdump, 010 Editor
CLI Tools: xxd (Linux/Mac), certutil (Windows), od Programming: Python hex()/bytes.hex(), JS toString(16) Analysis: Wireshark, Ghidra, IDA Pro, binwalk |
Why Convert JSON to HEX?
Converting JSON files to hexadecimal encoding is a specialized operation useful for debugging, binary analysis, and low-level data inspection. When you suspect encoding issues in a JSON file (such as incorrect UTF-8 sequences, hidden BOM markers, or invisible control characters), viewing the hex dump reveals the exact bytes that make up the file. This is invaluable for diagnosing "invalid JSON" errors caused by invisible characters.
Hex encoding is also essential in firmware development and embedded systems where JSON configuration data needs to be stored in flash memory or transmitted over binary protocols. Converting JSON to hex allows you to embed configuration data directly in C/C++ source code as byte arrays, include it in firmware images, or transmit it over serial or I2C protocols that operate at the byte level.
Our converter encodes every byte of the JSON file as two hexadecimal digits (00-FF). The output includes an optional ASCII sidebar showing printable characters, making it easy to correlate hex values with the original text. Offset addresses are included so you can navigate to specific positions in the file. This standard hex dump format is compatible with tools like xxd, HxD, and Hex Fiend.
Key Benefits of Converting JSON to HEX:
- Encoding Debugging: Identify hidden BOM markers, invisible characters, and UTF-8 encoding errors
- Byte-Level Inspection: See the exact bytes that make up your JSON file, including whitespace
- Firmware Embedding: Convert JSON config data to hex for inclusion in firmware images
- Protocol Analysis: Prepare JSON data for binary protocol transmission or inspection
- Security Forensics: Examine JSON payloads at the byte level for hidden data or anomalies
- Tool Compatibility: Output works with xxd, HxD, Hex Fiend, and other hex editor tools
Practical Examples
Example 1: Simple JSON Object
Input JSON file (data.json):
{"name":"Alice","age":30}
Output HEX file (data.hex):
00000000 7B 22 6E 61 6D 65 22 3A 22 41 6C 69 63 65 22 2C |{"name":"Alice",|
00000010 22 61 67 65 22 3A 33 30 7D |"age":30} |
Example 2: Configuration with Special Characters
Input JSON file (config.json):
{
"path": "C:\\Users\\data",
"url": "https://api.example.com",
"token": "abc123"
}
Output HEX file (config.hex):
00000000 7B 0A 20 20 22 70 61 74 68 22 3A 20 22 43 3A 5C |{. "path": "C:\|
00000010 5C 55 73 65 72 73 5C 5C 64 61 74 61 22 2C 0A 20 |\Users\\data",. |
00000020 20 22 75 72 6C 22 3A 20 22 68 74 74 70 73 3A 2F | "url": "https:/|
00000030 2F 61 70 69 2E 65 78 61 6D 70 6C 65 2E 63 6F 6D |/api.example.com|
00000040 22 2C 0A 20 20 22 74 6F 6B 65 6E 22 3A 20 22 61 |",. "token": "a|
00000050 62 63 31 32 33 22 0A 7D |bc123".} |
Example 3: Firmware Byte Array
Input JSON file (sensor.json):
{"sensor":"temp","value":22.5}
Output HEX file (sensor.hex):
00000000 7B 22 73 65 6E 73 6F 72 22 3A 22 74 65 6D 70 22 |{"sensor":"temp"|
00000010 2C 22 76 61 6C 75 65 22 3A 32 32 2E 35 7D |,"value":22.5} |
// C byte array representation:
const uint8_t json_data[] = {
0x7B, 0x22, 0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72,
0x22, 0x3A, 0x22, 0x74, 0x65, 0x6D, 0x70, 0x22,
0x2C, 0x22, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x22,
0x3A, 0x32, 0x32, 0x2E, 0x35, 0x7D
};
Frequently Asked Questions (FAQ)
Q: What is JSON format?
A: JSON (JavaScript Object Notation) is a lightweight data interchange format standardized as RFC 8259 and ECMA-404. It uses key-value pairs in objects (curly braces), ordered lists in arrays (square brackets), and supports strings, numbers, booleans, and null. JSON is the dominant format for web APIs, configuration files (package.json, tsconfig.json), and NoSQL databases like MongoDB.
Q: What is HEX (Hexadecimal) encoding?
A: Hexadecimal encoding represents each byte of data as two characters from the base-16 number system (digits 0-9 and letters A-F). For example, the letter "A" (ASCII 65) is represented as 41 in hex, and a space (ASCII 32) is 20. Hex encoding is the standard way to inspect raw binary data in debugging, firmware development, and forensic analysis.
Q: Why would I need to see JSON in hexadecimal?
A: The most common reason is debugging encoding issues. If a JSON parser reports "invalid character" errors but the file looks correct in a text editor, a hex dump can reveal hidden BOM markers (EF BB BF), zero-width spaces (E2 80 8B), or other invisible characters that cause parsing failures. It is also useful for verifying that special characters are correctly UTF-8 encoded.
Q: How large is the hex output compared to the original?
A: Raw hex encoding doubles the size because each byte (1 character) becomes 2 hex characters. With the standard hex dump format (offsets, spacing, ASCII sidebar), the output is approximately 3-4 times the original size. This is expected and normal for hex representations.
Q: Can I convert the hex output back to JSON?
A: Yes, hex encoding is fully reversible. You can convert the hex bytes back to text using tools like xxd -r (Linux/Mac), Python's bytes.fromhex(), or any hex editor's "save as binary" function. The original JSON content is preserved byte-for-byte in the hex representation.
Q: What hex dump format does the output use?
A: The output uses the standard hex dump format: offset addresses on the left, hex bytes in the center (grouped in pairs with spaces), and an ASCII representation on the right. This format is compatible with xxd, hexdump -C, and most hex editor tools. Non-printable characters appear as dots (.) in the ASCII column.
Q: What happens if my JSON file has syntax errors?
A: Hex encoding works on raw bytes, not parsed data, so JSON syntax errors do not affect the conversion. The converter encodes every byte of the file exactly as it exists on disk. This is actually one of the advantages -- you can hex-encode a malformed JSON file to inspect it at the byte level and find the source of the syntax error.