BCP 47 Validator

This service lets you validate language tags such as de-CH or en-US according to BCP 47 (formerly RFC 4646) and the IANA Language Subtag Registry. The Language Tag Extensions Registry is not used yet.

Enter one language tag per line. When JavaScript is enabled, the background color denotes whether all tags are well-formed and valid, any tag is invalid or any tag is not well-formed.

Language tags:
Output format:

Features

Examples

These language tags are well-formed and valid:

Regular expression

To parse a language tag and verify its well-formedness, this .NET-style regular expression is used:

^
(
  (
    (
      (
        (?'language'
          [a-z]{2,3}
        )
        (-
          (?'extlang'
            [a-z]{3}
          )
        ){0,3}
      )
      |
      (?'language'
        [a-z]{4}
      )
      |
      (?'language'
        [a-z]{5,8}
      )
    )

    (-(?'script'
      [a-z]{4}
    ))?

    (-(?'region'
      [a-z]{2}
      |
      [0-9]{3}
    ))?

    (-
      (?'variant'
        [a-z0-9]{5,8}
        |
        [0-9][a-z0-9]{3}
      )
    )*
    
    (-
      (?'extensions'
        [a-z0-9-[x]]
        (-
          [a-z0-9]{2,8}
        )+
      )
    )*
    
    (-
      x(- 
        (?'privateuse'
          [a-z0-9]{1,8}
        )
      )+
    )?
  )
  |
  (
    x(- 
      (?'privateuse'
        [a-z0-9]{1,8}
      )
    )+
  )
  |
  (?'grandfathered'
    (?'irregular'
      en-GB-oed |
      i-ami |
      i-bnn |
      i-default |
      i-enochian |
      i-hak |
      i-klingon |
      i-lux |
      i-mingo |
      i-navajo |
      i-pwn |
      i-tao |
      i-tay |
      i-tsu |
      sgn-BE-FR |
      sgn-BE-NL |
      sgn-CH-DE
    )
    |
    (?'regular'
      art-lojban |
      cel-gaulish |
      no-bok |
      no-nyn |
      zh-guoyu |
      zh-hakka |
      zh-min |
      zh-min-nan |
      zh-xiang
    )
  )
)
$

Feedback

Don't hesitate to send suggestions and comments to Christoph Schneegans (Christoph@Schneegans.de).