Vietnamese Accent Restoration API

Restore Vietnamese diacritics in text typed without accents (“xin chao cac ban” → “xin chào các bạn”) using a dictionary and syllable frequencies.

POSTGEThttps://apibox.io.vn/v1/vn-diacritics

The accent restoration API turns Vietnamese typed without diacritics, common in SMS, chats, old databases and product names, back into proper Vietnamese: Ngan hang Nha nuoc vua giam lai suat → Ngân hàng Nhà nước vừa giảm lãi suất. Each run of unaccented words is solved as a whole with dynamic programming: the API prefers sequences that form dictionary words of two to four syllables, then the most frequent syllables.

Capitalisation is kept (Ha Noi → Hà Nội, CONG TY → CÔNG TY), punctuation and numbers are left alone, and words that are not Vietnamese stay unchanged. alternatives=1–5 lists, for every ambiguous syllable, the other likely readings, so an interface can let the user pick (ban: bạn / bán / bàn).

It runs on a word list and frequency tables, without an AI model, in a few milliseconds. Results are good for common phrases and names; short or unusual sentences can need a human check. Text that is already partly accented is fine: syllables typed with accents are kept as they are and help choose the accents of their neighbours.

Parameters

NameInTypeRequiredDefault
textbody|querystringyesUnaccented Vietnamese text (max 20,000 characters).
alternativesbody|querynumberno0Other readings to list per ambiguous syllable (0–5).

Example

curl -X POST "https://apibox.io.vn/v1/vn-diacritics" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Ngan hang Nha nuoc vua giam lai suat dieu hanh","alternatives":2}'

Response

{
  "input": "Ngan hang Nha nuoc vua giam lai suat dieu hanh",
  "result": "Ngân hàng Nhà nước vừa giảm lãi suất điều hành",
  "syllables_changed": 10,
  "ambiguous_syllables": 8,
  "alternatives": [
    {
      "word": "Ngân",
      "position": 0,
      "options": [
        "ngân",
        "ngắn",
        "ngăn"
      ]
    },
    {
      "word": "vừa",
      "position": 19,
      "options": [
        "vừa",
        "vua",
        "vựa"
      ]
    },
    {
      "word": "lãi",
      "position": 28,
      "options": [
        "lai",
        "lại",
        "lãi"
      ]
    }
  ],
  "note": "Accents are chosen from a dictionary and syllable frequencies; ambiguous words (ban: bạn / bán / bàn) may need a human check."
}

Use cases

  • Fix product names and addresses imported without accents
  • Make SMS and chat messages readable
  • Restore accents in old database exports
  • Suggest accented text as the user types

FAQ

How accurate is it?

Common phrases come out right most of the time; ambiguous short words may be wrong, which is why alternatives are offered.

Does it use AI?

No, a dictionary of words and syllable frequencies with dynamic programming, so it is fast and deterministic.

Can I send text that already has some accents?

Yes. Syllables that already have accents are kept unchanged and only the unaccented ones are restored, e.g. “Hôm nay troi dep qua” → “Hôm nay trời đẹp quá”.

Related APIs

Start with 1,000 free requests every month. Get free API key →