GB2312 / GBK Encoder/Decoder

Simplified Chinese GBK byte encoding and decoding

Encode Simplified Chinese text to GBK / GB2312 byte sequences shown as hex, or decode GBK hex bytes back to text. Handles single-byte ASCII plus two-byte Chinese characters using the GBK superset, runs locally in your browser, and flags anything outside the repertoire. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is the difference between GB2312 and GBK?

GB2312 is the original 1980 standard covering common Simplified Chinese characters. GBK is a backward-compatible superset that adds thousands more characters. Any GB2312 byte sequence is valid GBK, so this tool uses the wider GBK table for both directions.

GB2312 and its backward-compatible superset GBK are the standard legacy encodings for Simplified Chinese on the mainland. ASCII stays single-byte while each Chinese character is stored as a two-byte sequence. This tool encodes Simplified Chinese text into GBK hex bytes and decodes GBK bytes back into text, using the wider GBK table so GB2312 data round-trips too.

How it works

ASCII characters 0x000x7F are one byte. Each Chinese character is two bytes: a lead byte in 0x810xFE followed by a trail byte in 0x400xFE (skipping 0x7F). GB2312 occupies a subset of this space, and GBK fills in the rest, which is why a single GBK decoder handles both.

To stay faithful to the real table, the tool enumerates the single-byte range and every valid lead/trail pair, decodes each with the browser’s native GBK decoder, and builds a character-to-bytes map. Encoding looks each character up in that map; decoding runs the hex bytes through the native decoder.

The GB encoding family tree

Understanding how these encodings relate helps when working with legacy Chinese data:

GB2312 (1980): The foundational standard. Covers 6,763 Simplified Chinese characters arranged in a 94×94 zone system, plus punctuation, Greek, Latin, Hiragana, Katakana, and other symbols. Zone 16–55 contains level-1 characters (sorted by pronunciation); zone 56–87 contains level-2 characters (sorted by radical/stroke). Still valid, but limited coverage of modern Chinese writing.

GBK (1993): A backward-compatible superset. Adds approximately 20,000 characters including Unified CJK characters, Traditional Chinese characters used in the mainland, user-defined zones, and additional punctuation. The K stands for 扩展 (kuòzhǎn, “extended”). Any byte sequence valid in GB2312 is valid GBK.

GB18030 (2000/2005/2022): The current mandatory Chinese national standard. A variable-length encoding (1, 2, or 4 bytes) that fully covers all Unicode characters. Backward-compatible with GBK. Required for software sold in China. The 4-byte extension uses a different byte range from the 2-byte range, so a GB18030 decoder can distinguish them.

This tool implements GBK, which handles virtually all real-world GB2312 and GBK files. For GB18030 4-byte characters, use a dedicated GB18030 tool or convert through Unicode.

When you encounter GBK in practice

GBK-encoded files are still common in several contexts:

  • Legacy Windows applications built for the Chinese market (Windows code page 936)
  • Older database exports from Chinese enterprise systems
  • Email and web content predating the widespread adoption of UTF-8
  • File formats from Chinese government and regulatory systems

When you open a file and see garbled Chinese characters (often described as “mojibake”), the most common cause is an encoding mismatch — a GBK file opened as UTF-8 or Latin-1. Use this tool to test a hex dump of the bytes against the GBK table to confirm the encoding.

Example

  • "中文" (zhōngwén, meaning “Chinese language”) encodes to D6 D0 CE C4 — two characters, each a two-byte pair: = D6 D0, = CE C4
  • ASCII mixed in: "abc中" encodes to 61 62 63 D6 D0 — the three ASCII bytes pass through as-is, then the Chinese character adds its two-byte sequence

GBK targets Simplified Chinese; Traditional-only characters and symbols outside the set are flagged as unmapped. For text that mixes scripts or needs emoji and rare characters, UTF-8 is the modern choice; GBK remains useful for interoperating with legacy Chinese files and systems.