User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
Category JSON Tools
Configuration
Input (.po)
JSON Result
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

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.

i18n gettext localization json converter developer tools

Formulas

The conversion process follows a linear parsing logic mapping Gettext blocks to JSON properties.

{
output.key = msgidoutput.value = msgstr

For complex entries with context, the key generation strategy changes to avoid collisions:

Key โ‰ก joinmsgctxtmsgid

Where the join function typically uses a delimiter (like _ or ::) depending on the target i18n library requirements.

Reference Data

PO KeywordJSON Equivalent (Simple)JSON Equivalent (Verbose)Description
msgidKeyidThe unique identifier for the translation string.
msgstrValuestrThe translated content.
msgctxtPrefix/NamespacecontextDisambiguates identical words (e.g., "Book" as noun vs. verb).
msgid_pluralIgnored in Simpleplural_idThe identifier for the plural form of the string.
msgstr[N]Ignored in Simpleplurals arraySpecific translations for count N (0, 1, 2...).
#IgnoredcommentsTranslator comments or references.

Frequently Asked Questions

In PO files, long strings are often split across multiple lines enclosed in quotes. This tool parses these lines and concatenates them into a single JSON string, removing the wrapping quotes and correctly interpreting escaped characters like \n and \".
Yes. In "Verbose" mode, the tool outputs an array of strings for plural forms (msgstr[0], msgstr[1], etc.). In "Simple" mode, it typically outputs the first singular form (msgstr[0]) as it maps 1:1 to key-value pairs.
The header (the entry with an empty msgid) contains metadata like charset and plural forms. In "Verbose" mode, this is preserved as a special key (usually empty string ""). In "Simple" mode, it is excluded to keep the dictionary clean.
No. This tool runs entirely in your browser using JavaScript. Your PO files are parsed locally and never leave your device.