---
title: "How do I escape braces and apostrophes in ICU message format?"
description: "Quote a literal brace with ASCII apostrophes, `'{'` and `'}'`, and write a literal apostrophe as `''`. In ICU an apostrophe only starts quoting before `{`, `}` or a plural's `#`, so `don't` needs no escaping; `java.text.MessageFormat` quotes on every apostrophe."
category: icu-message-format
date: 2026-10-09
canonical: https://localizely.com/i18n-questions/icu-message-format/how-do-i-escape-braces-and-apostrophes-in-icu-message-format/
---

# How do I escape braces and apostrophes in ICU message format?

Wrap a literal brace in ASCII apostrophes, `'{'` and `'}'`, and write a literal apostrophe as two apostrophes, `''`. In ICU's default apostrophe mode a single apostrophe only starts quoting when it immediately precedes a syntax character, so a plain `don't` in the text is printed as is.

The ASCII apostrophe (U+0027) is the quoting character of the syntax. Everything between it and the next apostrophe is copied literally, which is how you print braces without starting an argument:

```icu-message-format
Use '{name}' as the placeholder, not {name}.
```

With `name` set to `Ann` this prints `Use {name} as the placeholder, not Ann.` Two adjacent apostrophes always produce one apostrophe, inside or outside quoted text:

```icu-message-format
This '{isn''t}' a placeholder.
```

Output: `This {isn't} a placeholder.`

Which apostrophes start quoting depends on the implementation:

- ICU4C, ICU4J, Android's `android.icu.text.MessageFormat`, PHP's `MessageFormatter` and FormatJS use ICU's "double optional" mode, the default since ICU 4.8. An apostrophe starts quoted text only when it immediately precedes `{` or `}`, a `#` inside a plural branch, or a `|` inside the old choice format. Every other apostrophe is literal, so `It's {count} items` prints `It's 3 items`. FormatJS additionally lets an apostrophe quote `<` and `>` because of its rich-text tags.
- [`java.text.MessageFormat`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/text/MessageFormat.html) treats every single apostrophe as the start of quoted text, the mode ICU calls "double required". There you must write `It''s {0} items`; the pattern `It's {0} items` quotes everything after the apostrophe and prints `Its {0} items`.

For user-facing text the safest choice is the typographic apostrophe ’ (U+2019). It is never a quoting character in any implementation, it is the correct glyph in English prose, and both the [ICU user guide](https://unicode-org.github.io/icu/userguide/format_parse/messages/#quotingescaping) and [FormatJS](https://formatjs.github.io/docs/core-concepts/icu-syntax/) recommend it for human-readable strings, leaving U+0027 to the syntax.

Pitfalls:

- A quote runs to the next apostrophe or to the end of the message, so one stray `'{` silently turns every later placeholder into literal text.
- `''` is portable, since both modes turn a pair into one apostrophe. A single apostrophe not followed by a syntax character is the only case where ICU and the JDK disagree, which matters when the same resource file is read by both.

The [ICU message editor](/icu-message-editor/) shows the output of a message, which is a quick way to check a quoted pattern.

Source: https://localizely.com/i18n-questions/icu-message-format/how-do-i-escape-braces-and-apostrophes-in-icu-message-format/
