XML Bitmap Font to JSON Converter
Convert BMFont XML bitmap font files to JSON format instantly in your browser. No upload needed. Supports AngelCode BMFont format with full char and kerning data.
About
AngelCode BMFont exports font metrics as XML. Many game engines and rendering frameworks require JSON instead. Manually restructuring char entries with attributes like x, y, width, height, xoffset, yoffset, and xadvance across hundreds of glyphs is error-prone. A mistyped id value or dropped kerning pair breaks text rendering at runtime with no obvious diagnostic. This tool parses BMFont XML via the browser's native DOMParser, extracts every attribute with correct integer coercion, and outputs valid JSON matching the format expected by frameworks like Pixi.js, Phaser, and CocoonJS.
The converter handles all BMFont XML elements: info (face, size, charset metadata), common (lineHeight, base, scale dimensions), pages (texture atlas references), chars (per-glyph metrics), and kernings (pair adjustments). Numeric attributes are coerced to integers automatically. Padding and spacing arrays are preserved as comma-separated strings or split into arrays depending on output mode. The tool processes files entirely client-side. Nothing leaves your browser.
Formulas
The conversion follows a deterministic mapping from XML DOM to JSON object. No mathematical formula is involved. The logic is a structural transformation.
parse(xmlString) → DOMTree
extract(DOMTree, tagName) → [element0, element1, …, elementn]
For each element: attributes(element) → { keyi: coerce(valuei) }
Type coercion rule:
where v = raw attribute value from XML, DOMTree = browser-native DOM representation, tagName ∈ {info, common, page, char, kerning}.
Reference Data
| BMFont XML Element | Key Attributes | JSON Output Key | Type | Description |
|---|---|---|---|---|
| info | face, size, bold, italic, charset, unicode, stretchH, smooth, aa, padding, spacing | info | Object | Font metadata: name, render size, style flags |
| common | lineHeight, base, scaleW, scaleH, pages, packed | common | Object | Shared metrics: line spacing, texture atlas dimensions |
| page | id, file | pages | Array | Texture atlas page references |
| char | id, x, y, width, height, xoffset, yoffset, xadvance, page, chnl | chars | Array | Per-glyph bounding box and advance metrics |
| kerning | first, second, amount | kernings | Array | Pair kerning adjustments between two glyph IDs |
| Attribute: id | - | id | Integer | Unicode code point for the glyph |
| Attribute: x | - | x | Integer | Left edge in texture atlas (pixels) |
| Attribute: y | - | y | Integer | Top edge in texture atlas (pixels) |
| Attribute: width | - | width | Integer | Glyph width in texture (pixels) |
| Attribute: height | - | height | Integer | Glyph height in texture (pixels) |
| Attribute: xoffset | - | xoffset | Integer | Horizontal offset when rendering |
| Attribute: yoffset | - | yoffset | Integer | Vertical offset from line top |
| Attribute: xadvance | - | xadvance | Integer | Cursor advance after glyph (pixels) |
| Attribute: lineHeight | - | lineHeight | Integer | Distance between baselines (pixels) |
| Attribute: base | - | base | Integer | Baseline offset from top of line (pixels) |
| Attribute: scaleW | - | scaleW | Integer | Texture atlas width (pixels) |
| Attribute: scaleH | - | scaleH | Integer | Texture atlas height (pixels) |
| Attribute: padding | - | padding | String/Array | Glyph padding: up,right,down,left |
| Attribute: spacing | - | spacing | String/Array | Glyph spacing: horizontal,vertical |