PO to JSON Converter
Convert Gettext .po files to JSON for i18n. Supports contexts, plurals, and multiline strings. Free, client-side, and privacy-focused.
About
Localization workflow often breaks when moving from backend-heavy systems (PHP, Python) to modern client-side applications. The .po (Portable Object) format, a standard in the Gettext ecosystem, is rarely natively supported by JavaScript i18n libraries, which prefer JSON.
This tool bridges that gap by parsing the strict, line-based Gettext syntax and transforming it into a structured JSON object. Unlike regex-based hacks which fail on multiline strings or escaped quotes, this tool implements a dedicated lexer. It handles critical edge cases like msgctxt (Contexts), msgid_plural (Pluralization), and header meta-data extraction. This ensures that your translation keys remain intact and usable in libraries like i18next or react-intl.
Formulas
The conversion process follows a linear parsing logic mapping Gettext blocks to JSON properties.
For complex entries with context, the key generation strategy changes to avoid collisions:
Where the join function typically uses a delimiter (like _ or ::) depending on the target i18n library requirements.
Reference Data
| PO Keyword | JSON Equivalent (Simple) | JSON Equivalent (Verbose) | Description |
|---|---|---|---|
| msgid | Key | id | The unique identifier for the translation string. |
| msgstr | Value | str | The translated content. |
| msgctxt | Prefix/Namespace | context | Disambiguates identical words (e.g., "Book" as noun vs. verb). |
| msgid_plural | Ignored in Simple | plural_id | The identifier for the plural form of the string. |
| msgstr[N] | Ignored in Simple | plurals array | Specific translations for count N (0, 1, 2...). |
| # | Ignored | comments | Translator comments or references. |