ICU MessageFormat Syntax Validator
Analyze ICU MessageFormat messages detecting malformed placeholders, plurals missing the other case, missing select branches and invalid types.
Understanding ICU MessageFormat
ICU MessageFormat is the message syntax used for internationalization (i18n) by tools such as FormatJS / react-intl, MessageFormat.js, and the ICU4J / ICU4C libraries. It lets a single localized string adapt to runtime values โ counts, genders, currencies, dates โ without hardcoding grammar for each language. Validating a message means checking that braces are balanced and that every argument uses a known type with valid sub-syntax.
Placeholders and argument types
The simplest placeholder is just a name in braces: Hello, {name}!. Typed arguments add a type and options:
- plural:
{count, plural, one {# item} other {# items}} - select:
{g, select, male {he} female {she} other {they}} - number:
{n, number, ::currency/USD} - date / time:
{d, date, short} - Other types include selectordinal and the deprecated choice.
Inside a plural block, the # symbol is replaced by the formatted count. Always provide an other branch โ it is the required fallback.
Escaping literals
Because braces and # are special, you escape literal characters with apostrophes. A single quote starts and ends a literal section, and '' produces a literal apostrophe. So '{not a placeholder}' renders the braces verbatim.
Common pitfalls
- Unbalanced braces โ an opening
{with no matching}. - Omitting the mandatory
otherbranch in apluralorselect. - Using an unknown argument type (e.g.
fooinstead ofplural/select/number). - Forgetting that
#only works inside aplural/selectordinal, not elsewhere. - Putting a literal apostrophe without doubling it, which silently starts an escape.
FAQ
What is the difference between plural and select? plural matches CLDR plural categories (one, other, etc.) for a number, while select matches arbitrary string keys you define, such as a gender value.
Why must I always include other? It is the guaranteed fallback when no other case matches, and languages differ wildly in their plural rules, so the parser enforces it.
Is choice safe to use? No โ the choice argument type is deprecated. Use plural or select instead.
Related Tools
CPF Validator
Validate Brazilian CPF numbers instantly using the official algorithm. Useful for testing document validation in applications. No data sent to servers.
Batch CPF Validator
Validate a list of CPFs (one per line) and see which are valid and which are not. No data sent to servers.
Batch CNPJ Validator
Validate a list of CNPJs (one per line) with a summary of valid, invalid and total. No data sent to servers.