Pig Latin Converter
Convert any English word or phrase to Pig Latin instantly. Handles consonant clusters, capitalization, punctuation, contractions, and edge cases.
About
Pig Latin is a language game that applies deterministic transformation rules to English words. The algorithm is deceptively simple until you encounter consonant clusters like str, qu digraphs, capitalization transfer, and trailing punctuation preservation. A naive implementation breaks on words like "square" (correct: aresquay), "rhythm" (where y functions as a vowel), or "I'm" (contraction with apostrophe). This converter implements the full canonical ruleset including qu-cluster handling, capital letter migration, hyphenated compound words, and punctuation anchoring. It does not handle proper nouns or acronyms differently from common words. Input is assumed to be standard English text.
Pro tip: Pig Latin has no single authoritative standard. Regional variations exist. This tool follows the most widely accepted ruleset where words starting with vowels receive the suffix yay and consonant-initial words rotate the leading cluster and append ay. Edge case: all-consonant strings (rare in English, e.g., "nth") move the entire word and append ay, producing nthay.
Formulas
The Pig Latin transformation applies a piecewise function to each word W based on its leading phoneme structure:
Where k is the index of the first vowel in W. The vowel set V = {a, e, i, o, u}, with y included in V when its position j > 0 (i.e., y is not the first letter). The qu digraph rule extends the consonant cluster: if W[k β 1] = q and W[k] = u, then k = k + 1.
Capitalization is transferred via a bitmask: capture the case pattern of the original word, apply the same pattern positionally to the transformed word. For all-caps words, the entire output is uppercased. Trailing punctuation is captured by the regular expression pattern = /([a-zA-Z']+)([^a-zA-Z]*)$/, stripped before transformation, and reattached after.
Reference Data
| English Word | Leading Sound | Rule Applied | Pig Latin Result |
|---|---|---|---|
| apple | Vowel (a) | Append yay | appleyay |
| banana | Single consonant (b) | Move b, append ay | ananabay |
| cherry | Cluster (ch) | Move ch, append ay | errychay |
| string | Cluster (str) | Move str, append ay | ingstray |
| queen | Cluster (qu) | Move qu, append ay | eenquay |
| square | Cluster (squ) | Move squ, append ay | aresquay |
| rhythm | Cluster (rh), y as vowel | Move rh, append ay | ythmrhay |
| egg | Vowel (e) | Append yay | eggyay |
| I | Vowel (I) | Append yay, preserve case | Iyay |
| Hello | Single consonant (H) | Move h, capitalize new first letter | Ellohay |
| HELLO | All caps (H) | Preserve all-caps | ELLOHAY |
| hello! | Single consonant, trailing punctuation | Move h, keep ! at end | ellohay! |
| well-known | Hyphenated compound | Convert each part independently | ellway-ownknay |
| I'm | Vowel with contraction | Append yay, preserve apostrophe | I'myay |
| school | Cluster (sch) | Move sch, append ay | oolschay |
| three | Cluster (thr) | Move thr, append ay | eethray |
| nth | All consonants | Move all, append ay | nthay |
| yellow | Consonant y at start | Move y, append ay | ellowyay |
| my | Single consonant (m), y as vowel | Move m, append ay | ymay |
| the | Cluster (th) | Move th, append ay | ethay |