Capitalization Tool – Complete v3.2 Rules
All capitalization rules from “How to Capitalize Anything”
This free capitalization tool checks your text against standard capitalization rules — proper nouns, titles, days, months, holidays, languages, religions, military titles, and more. Paste in a sentence, a paragraph, or an entire document, and the capitalization tool will flag every error and show you exactly what changed and why. Built for writers, editors, teachers, and students. Based on the rules in How to Capitalize Anything.
Result:
const MONUMENTS = { 'statue of liberty':'Statue of Liberty','eiffel tower':'Eiffel Tower','big ben':'Big Ben', 'leaning tower of pisa':'Leaning Tower of Pisa','colosseum':'Colosseum', 'empire state building':'Empire State Building','hollywood sign':'Hollywood Sign', 'golden gate bridge':'Golden Gate Bridge','notre dame cathedral':'Notre Dame Cathedral', 'tokyo tower':'Tokyo Tower',"st. peter's basilica":"St. Peter's Basilica", "st peter's basilica":"St. Peter's Basilica",'sagrada familia':'Sagrada Familia', 'great wall of china':'Great Wall of China','sydney opera house':'Sydney Opera House', "st. basil's cathedral":"St. Basil's Cathedral", 'arc de triomphe':'Arc de Triomphe','berlin wall':'Berlin Wall','stonehenge':'Stonehenge', 'taj mahal':'Taj Mahal','pyramids of giza':'Pyramids of Giza','great sphinx':'Great Sphinx', 'tower bridge':'Tower Bridge','forbidden city':'Forbidden City','capitol hill':'Capitol Hill', 'willis tower':'Willis Tower','sears tower':'Sears Tower','brooklyn bridge':'Brooklyn Bridge', 'acropolis':'Acropolis','trevi fountain':'Trevi Fountain', "st. mark's basilica":"St. Mark's Basilica", 'times square':'Times Square','white house':'White House','louvre museum':'Louvre Museum', 'the louvre':'the Louvre','louvre':'Louvre','manneken pis':'Manneken Pis', 'buckingham palace':'Buckingham Palace','versailles':'Versailles', 'neuschwanstein castle':'Neuschwanstein Castle','pompeii':'Pompeii', 'florence cathedral':'Florence Cathedral','edinburgh castle':'Edinburgh Castle', 'machu picchu':'Machu Picchu','christ the redeemer':'Christ the Redeemer', 'cn tower':'CN Tower','grand canyon':'Grand Canyon','niagara falls':'Niagara Falls', 'burj khalifa':'Burj Khalifa','tower of london':'Tower of London', 'petronas twin towers':'Petronas Twin Towers','windsor castle':'Windsor Castle', 'sacre coeur':'Sacre Coeur',"st. paul's cathedral":"St. Paul's Cathedral", 'central park':'Central Park','mount rushmore':'Mount Rushmore', 'space needle':'Space Needle','westminster abbey':'Westminster Abbey', 'rock of gibraltar':'Rock of Gibraltar','alcatraz':'Alcatraz','angkor wat':'Angkor Wat', 'chichen itza':'Chichen Itza','mount everest':'Mount Everest', 'mount kilimanjaro':'Mount Kilimanjaro','denali':'Denali', 'mount fuji':'Mount Fuji','mount etna':'Mount Etna','mount vesuvius':'Mount Vesuvius', 'mount olympus':'Mount Olympus','mount rainier':'Mount Rainier', 'mount st. helens':'Mount St. Helens','mount whitney':'Mount Whitney', 'mount hood':'Mount Hood','mount shasta':'Mount Shasta', 'mount katahdin':'Mount Katahdin','ben nevis':'Ben Nevis','snowdon':'Snowdon', 'matterhorn':'Matterhorn','mont blanc':'Mont Blanc','uluru':'Uluru', 'ayers rock':'Ayers Rock','table mountain':'Table Mountain', 'smithsonian institution':'Smithsonian Institution','smithsonian':'Smithsonian', 'washington monument':'Washington Monument','lincoln memorial':'Lincoln Memorial', 'jefferson memorial':'Jefferson Memorial','the vatican':'the Vatican', 'vatican city':'Vatican City','vatican':'Vatican','astrodome':'Astrodome', 'pantheon':'Pantheon','piazza navona':'Piazza Navona', 'spanish steps':'Spanish Steps',"castel sant'angelo":"Castel Sant'Angelo", 'palatine hill':'Palatine Hill','roman forum':'Roman Forum', 'sistine chapel':'Sistine Chapel',"st. peter's square":"St. Peter's Square", 'borghese gallery':'Borghese Gallery','piazza del popolo':'Piazza del Popolo', 'liberty bell':'Liberty Bell','independence hall':'Independence Hall', 'the alamo':'the Alamo','alamo':'Alamo', 'metropolitan museum of art':'Metropolitan Museum of Art', 'the met':'the Met','met museum':'Met Museum' };
const GEO_REGIONS = { 'pacific northwest':'Pacific Northwest','great plains':'Great Plains', 'gulf coast':'Gulf Coast','new england':'New England', 'corn belt':'Corn Belt','rust belt':'Rust Belt','bible belt':'Bible Belt', 'sun belt':'Sun Belt','mountain west':'Mountain West', 'tri-state area':'Tri-State Area','mid-atlantic states':'Mid-Atlantic States', 'the southwest':'the Southwest','southwest':'Southwest', 'the southeast':'the Southeast','southeast':'Southeast', 'northern ireland':'Northern Ireland','western australia':'Western Australia', 'south australia':'South Australia','northern territory':'Northern Territory', 'new south wales':'New South Wales','western sahara':'Western Sahara', 'middle east':'Middle East','far east':'Far East', 'east asia':'East Asia','southeast asia':'Southeast Asia', 'south pacific':'South Pacific','north atlantic':'North Atlantic', 'central america':'Central America', 'eastern bloc':'Eastern Bloc','western bloc':'Western Bloc', 'eastern seaboard':'Eastern Seaboard','western hemisphere':'Western Hemisphere', 'northern hemisphere':'Northern Hemisphere','southern hemisphere':'Southern Hemisphere', 'the south':'the South','the north':'the North', 'the east':'the East','the west':'the West','the midwest':'the Midwest', 'southerners':'Southerners','northerners':'Northerners', 'westerners':'Westerners','easterners':'Easterners','midwesterners':'Midwesterners', 'lower east side':'Lower East Side','outer banks':'Outer Banks', 'texas panhandle':'Texas Panhandle','hill country':'Hill Country', 'texas hill country':'Texas Hill Country', 'upper midwest':'Upper Midwest','rocky mountains':'Rocky Mountains', 'the south side':'the South Side','south side':'South Side', 'north shore':'North Shore','upstate new york':'Upstate New York', 'northern virginia':'Northern Virginia','eastern shore':'Eastern Shore', 'nob hill':'Nob Hill','russian hill':'Russian Hill','soma':'SoMa', 'beacon hill':'Beacon Hill','little italy':'Little Italy', 'greenwich village':'Greenwich Village','french quarter':'French Quarter', 'haight-ashbury':'Haight-Ashbury','chinatown':'Chinatown','harlem':'Harlem', 'tribeca':'TriBeCa','soho':'SoHo','park slope':'Park Slope', 'williamsburg':'Williamsburg','west village':'West Village', 'east village':'East Village','financial district':'Financial District', 'upper west side':'Upper West Side','upper east side':'Upper East Side', 'brooklyn heights':'Brooklyn Heights','south boston':'South Boston', 'south bronx':'South Bronx','north hollywood':'North Hollywood', 'east los angeles':'East Los Angeles','west los angeles':'West Los Angeles', 'central valley':'Central Valley','inland empire':'Inland Empire', 'heartland':'Heartland','low country':'Low Country', 'eastern kentucky':'Eastern Kentucky','south chicago':'South Chicago', 'south philadelphia':'South Philadelphia','south philly':'South Philly', 'west end':'West End','east end':'East End','east bay':'East Bay', 'west side':'West Side','east side':'East Side', 'north vancouver':'North Vancouver' };
const US_STATES = { 'alabama':'Alabama','alaska':'Alaska','arizona':'Arizona','arkansas':'Arkansas', 'california':'California','colorado':'Colorado','connecticut':'Connecticut', 'delaware':'Delaware','florida':'Florida','georgia':'Georgia','hawaii':'Hawaii', 'idaho':'Idaho','illinois':'Illinois','indiana':'Indiana','iowa':'Iowa', 'kansas':'Kansas','kentucky':'Kentucky','louisiana':'Louisiana','maine':'Maine', 'maryland':'Maryland','massachusetts':'Massachusetts','michigan':'Michigan', 'minnesota':'Minnesota','mississippi':'Mississippi','missouri':'Missouri', 'montana':'Montana','nebraska':'Nebraska','nevada':'Nevada', 'new hampshire':'New Hampshire','new jersey':'New Jersey','new mexico':'New Mexico', 'new york':'New York','north carolina':'North Carolina','north dakota':'North Dakota', 'ohio':'Ohio','oklahoma':'Oklahoma','oregon':'Oregon','pennsylvania':'Pennsylvania', 'rhode island':'Rhode Island','south carolina':'South Carolina', 'south dakota':'South Dakota','tennessee':'Tennessee','texas':'Texas', 'utah':'Utah','vermont':'Vermont','virginia':'Virginia','washington':'Washington', 'west virginia':'West Virginia','wisconsin':'Wisconsin','wyoming':'Wyoming' };
const CANADIAN_PROVINCES = { 'alberta':'Alberta','british columbia':'British Columbia','manitoba':'Manitoba', 'new brunswick':'New Brunswick','newfoundland and labrador':'Newfoundland and Labrador', 'northwest territories':'Northwest Territories','nova scotia':'Nova Scotia', 'nunavut':'Nunavut','ontario':'Ontario','prince edward island':'Prince Edward Island', 'quebec':'Quebec','saskatchewan':'Saskatchewan','yukon':'Yukon' };
const BOOK_TITLES = { 'to kill a mockingbird':'To Kill a Mockingbird', 'the grapes of wrath':'The Grapes of Wrath', 'of mice and men':'Of Mice and Men', 'the old man and the sea':'The Old Man and the Sea', 'for whom the bell tolls':'For Whom the Bell Tolls', 'a farewell to arms':'A Farewell to Arms', 'the sun also rises':'The Sun Also Rises', 'the great gatsby':'The Great Gatsby', 'in cold blood':'In Cold Blood', 'a tale of two cities':'A Tale of Two Cities', 'great expectations':'Great Expectations', 'oliver twist':'Oliver Twist', 'david copperfield':'David Copperfield', 'bleak house':'Bleak House', 'pride and prejudice':'Pride and Prejudice', 'sense and sensibility':'Sense and Sensibility', 'mansfield park':'Mansfield Park', 'northanger abbey':'Northanger Abbey', 'jane eyre':'Jane Eyre', 'wuthering heights':'Wuthering Heights', 'middlemarch':'Middlemarch', 'far from the madding crowd':'Far from the Madding Crowd', 'the return of the native':'The Return of the Native', 'jude the obscure':'Jude the Obscure', 'treasure island':'Treasure Island', 'the picture of dorian gray':'The Picture of Dorian Gray', 'heart of darkness':'Heart of Darkness', 'animal farm':'Animal Farm', 'nineteen eighty-four':'Nineteen Eighty-Four', '1984':'1984','brave new world':'Brave New World', 'lord of the flies':'Lord of the Flies', 'the catcher in the rye':'The Catcher in the Rye', 'on the road':'On the Road','catch-22':'Catch-22', 'slaughterhouse-five':'Slaughterhouse-Five','beloved':'Beloved', 'the color purple':'The Color Purple', 'their eyes were watching god':'Their Eyes Were Watching God', 'invisible man':'Invisible Man','native son':'Native Son', 'the sound and the fury':'The Sound and the Fury', 'as i lay dying':'As I Lay Dying','light in august':'Light in August', 'the adventures of huckleberry finn':'The Adventures of Huckleberry Finn', 'the adventures of tom sawyer':'The Adventures of Tom Sawyer', 'moby-dick':'Moby-Dick','moby dick':'Moby-Dick', 'the scarlet letter':'The Scarlet Letter','little women':'Little Women', 'the call of the wild':'The Call of the Wild','white fang':'White Fang', 'the red badge of courage':'The Red Badge of Courage', 'the age of innocence':'The Age of Innocence', 'the house of mirth':'The House of Mirth', 'the lord of the rings':'The Lord of the Rings', 'the fellowship of the ring':'The Fellowship of the Ring', 'the two towers':'The Two Towers','the return of the king':'The Return of the King', 'the hobbit':'The Hobbit','dune':'Dune','foundation':'Foundation', 'fahrenheit 451':'Fahrenheit 451',"the handmaid's tale":"The Handmaid's Tale", 'neuromancer':'Neuromancer', "one flew over the cuckoo's nest":"One Flew Over the Cuckoo's Nest", 'blood meridian':'Blood Meridian','no country for old men':'No Country for Old Men', 'the road':'The Road','all the pretty horses':'All the Pretty Horses', 'lonesome dove':'Lonesome Dove','the stand':'The Stand','the shining':'The Shining', 'carrie':'Carrie','pet sematary':'Pet Sematary','misery':'Misery', 'the firm':'The Firm','a time to kill':'A Time to Kill', 'the pelican brief':'The Pelican Brief','gone with the wind':'Gone with the Wind', 'the help':'The Help','cold mountain':'Cold Mountain', 'a confederacy of dunces':'A Confederacy of Dunces', 'the da vinci code':'The Da Vinci Code', 'the girl with the dragon tattoo':'The Girl with the Dragon Tattoo', 'gone girl':'Gone Girl','sharp objects':'Sharp Objects', 'the silent patient':'The Silent Patient','big little lies':'Big Little Lies', 'where the crawdads sing':'Where the Crawdads Sing','the nightingale':'The Nightingale', "harry potter and the sorcerer's stone":"Harry Potter and the Sorcerer's Stone", 'harry potter and the chamber of secrets':'Harry Potter and the Chamber of Secrets', 'harry potter and the prisoner of azkaban':'Harry Potter and the Prisoner of Azkaban', 'harry potter and the goblet of fire':'Harry Potter and the Goblet of Fire', 'harry potter and the order of the phoenix':'Harry Potter and the Order of the Phoenix', 'harry potter and the half-blood prince':'Harry Potter and the Half-Blood Prince', 'harry potter and the deathly hallows':'Harry Potter and the Deathly Hallows', 'the hunger games':'The Hunger Games','catching fire':'Catching Fire', 'mockingjay':'Mockingjay','a game of thrones':'A Game of Thrones', 'a clash of kings':'A Clash of Kings','a storm of swords':'A Storm of Swords', 'a feast for crows':'A Feast for Crows','a dance with dragons':'A Dance with Dragons', 'the name of the wind':'The Name of the Wind','american gods':'American Gods', 'good omens':'Good Omens','coraline':'Coraline', 'crime and punishment':'Crime and Punishment', 'the brothers karamazov':'The Brothers Karamazov','war and peace':'War and Peace', 'anna karenina':'Anna Karenina','les miserables':'Les Misérables', 'the count of monte cristo':'The Count of Monte Cristo', 'the three musketeers':'The Three Musketeers','don quixote':'Don Quixote', 'the metamorphosis':'The Metamorphosis','the stranger':'The Stranger', 'the plague':'The Plague','siddhartha':'Siddhartha', 'all quiet on the western front':'All Quiet on the Western Front', 'one hundred years of solitude':'One Hundred Years of Solitude', 'love in the time of cholera':'Love in the Time of Cholera', 'the kite runner':'The Kite Runner','a thousand splendid suns':'A Thousand Splendid Suns', 'the god of small things':'The God of Small Things', 'the remains of the day':'The Remains of the Day','never let me go':'Never Let Me Go', 'atonement':'Atonement','the corrections':'The Corrections', 'american pastoral':'American Pastoral','the book thief':'The Book Thief', 'all the light we cannot see':'All the Light We Cannot See','night':'Night', 'the alchemist':'The Alchemist',"charlotte's web":"Charlotte's Web", 'the little prince':'The Little Prince','a wrinkle in time':'A Wrinkle in Time', 'the giver':'The Giver','the outsiders':'The Outsiders', 'the things they carried':'The Things They Carried', "the time traveler's wife":"The Time Traveler's Wife", 'the lovely bones':'The Lovely Bones','life of pi':'Life of Pi', 'me before you':'Me Before You', 'the year of magical thinking':'The Year of Magical Thinking', 'a streetcar named desire':'A Streetcar Named Desire', 'the glass menagerie':'The Glass Menagerie','death of a salesman':'Death of a Salesman', 'the crucible':'The Crucible', "long day's journey into night":"Long Day's Journey into Night", 'the iceman cometh':'The Iceman Cometh','a raisin in the sun':'A Raisin in the Sun', 'fences':'Fences', 'the adventures of sherlock holmes':'The Adventures of Sherlock Holmes', 'the hound of the baskervilles':'The Hound of the Baskervilles', 'and then there were none':'And Then There Were None', 'murder on the orient express':'Murder on the Orient Express', 'death on the nile':'Death on the Nile', 'the murder of roger ackroyd':'The Murder of Roger Ackroyd', 'the maltese falcon':'The Maltese Falcon','the big sleep':'The Big Sleep', 'farewell my lovely':'Farewell, My Lovely','the long goodbye':'The Long Goodbye', 'the thin man':'The Thin Man', 'the postman always rings twice':'The Postman Always Rings Twice', 'double indemnity':'Double Indemnity','the godfather':'The Godfather', "winnie-the-pooh":'Winnie-the-Pooh','winnie the pooh':'Winnie-the-Pooh', "alice's adventures in wonderland":"Alice's Adventures in Wonderland", 'alice in wonderland':'Alice in Wonderland','peter pan':'Peter Pan', 'the wind in the willows':'The Wind in the Willows', 'the secret garden':'The Secret Garden', 'james and the giant peach':'James and the Giant Peach', 'charlie and the chocolate factory':'Charlie and the Chocolate Factory', 'matilda':'Matilda','dracula':'Dracula','frankenstein':'Frankenstein', 'the jungle book':'The Jungle Book' };
const MOVIE_TITLES = { 'casablanca':'Casablanca','citizen kane':'Citizen Kane', 'gone with the wind':'Gone with the Wind','the wizard of oz':'The Wizard of Oz', "it's a wonderful life":"It's a Wonderful Life", 'sunset boulevard':'Sunset Boulevard','all about eve':'All About Eve', 'some like it hot':'Some Like It Hot','rear window':'Rear Window', 'vertigo':'Vertigo','psycho':'Psycho','north by northwest':'North by Northwest', 'the birds':'The Birds','on the waterfront':'On the Waterfront', 'the godfather':'The Godfather','the godfather part ii':'The Godfather Part II', 'goodfellas':'Goodfellas','the departed':'The Departed','taxi driver':'Taxi Driver', 'raging bull':'Raging Bull','the irishman':'The Irishman', 'killers of the flower moon':'Killers of the Flower Moon', 'apocalypse now':'Apocalypse Now', "one flew over the cuckoo's nest":"One Flew Over the Cuckoo's Nest", 'chinatown':'Chinatown',"breakfast at tiffany's":"Breakfast at Tiffany's", 'roman holiday':'Roman Holiday','the philadelphia story':'The Philadelphia Story', 'it happened one night':'It Happened One Night','american beauty':'American Beauty', 'the shawshank redemption':'The Shawshank Redemption', "schindler's list":"Schindler's List",'saving private ryan':'Saving Private Ryan', 'raiders of the lost ark':'Raiders of the Lost Ark','jaws':'Jaws', 'jurassic park':'Jurassic Park','star wars':'Star Wars', 'the empire strikes back':'The Empire Strikes Back', 'return of the jedi':'Return of the Jedi','the force awakens':'The Force Awakens', 'the last jedi':'The Last Jedi','back to the future':'Back to the Future', 'the terminator':'The Terminator','alien':'Alien','aliens':'Aliens', 'blade runner':'Blade Runner','blade runner 2049':'Blade Runner 2049', 'the matrix':'The Matrix','the matrix reloaded':'The Matrix Reloaded', 'gladiator':'Gladiator','braveheart':'Braveheart', 'dances with wolves':'Dances with Wolves','the revenant':'The Revenant', 'titanic':'Titanic','avatar':'Avatar','the dark knight':'The Dark Knight', 'batman begins':'Batman Begins','iron man':'Iron Man','the avengers':'The Avengers', 'avengers endgame':'Avengers: Endgame','black panther':'Black Panther', 'the silence of the lambs':'The Silence of the Lambs','seven':'Seven', 'fight club':'Fight Club','the social network':'The Social Network', 'gone girl':'Gone Girl','no country for old men':'No Country for Old Men', 'fargo':'Fargo','the big lebowski':'The Big Lebowski','true grit':'True Grit', "o brother where art thou":"O Brother, Where Art Thou?", 'pulp fiction':'Pulp Fiction','reservoir dogs':'Reservoir Dogs', 'kill bill':'Kill Bill','inglourious basterds':'Inglourious Basterds', 'django unchained':'Django Unchained', 'once upon a time in hollywood':'Once Upon a Time in Hollywood', 'memento':'Memento','inception':'Inception','the prestige':'The Prestige', 'interstellar':'Interstellar','dunkirk':'Dunkirk','oppenheimer':'Oppenheimer', 'forrest gump':'Forrest Gump','cast away':'Cast Away','the green mile':'The Green Mile', 'dune':'Dune','dune part two':'Dune: Part Two','the martian':'The Martian', 'arrival':'Arrival','mad max fury road':'Mad Max: Fury Road', 'full metal jacket':'Full Metal Jacket','2001 a space odyssey':'2001: A Space Odyssey', 'a clockwork orange':'A Clockwork Orange','the lion king':'The Lion King', 'beauty and the beast':'Beauty and the Beast','aladdin':'Aladdin', 'the little mermaid':'The Little Mermaid','toy story':'Toy Story', 'toy story 2':'Toy Story 2','toy story 3':'Toy Story 3','toy story 4':'Toy Story 4', "a bug's life":"A Bug's Life",'monsters inc':'Monsters, Inc.', 'finding nemo':'Finding Nemo','the incredibles':'The Incredibles', 'ratatouille':'Ratatouille','wall-e':'WALL-E','up':'Up','brave':'Brave', 'inside out':'Inside Out','coco':'Coco','soul':'Soul','shrek':'Shrek', 'top gun':'Top Gun','top gun maverick':'Top Gun: Maverick', 'when harry met sally':'When Harry Met Sally','notting hill':'Notting Hill', 'four weddings and a funeral':'Four Weddings and a Funeral', 'love actually':'Love Actually','good will hunting':'Good Will Hunting', 'dead poets society':'Dead Poets Society','a few good men':'A Few Good Men', 'rain man':'Rain Man','the bridge on the river kwai':'The Bridge on the River Kwai', 'the great escape':'The Great Escape','patton':'Patton','hacksaw ridge':'Hacksaw Ridge', 'the thin red line':'The Thin Red Line','platoon':'Platoon', 'the deer hunter':'The Deer Hunter','the hurt locker':'The Hurt Locker', 'zero dark thirty':'Zero Dark Thirty','american sniper':'American Sniper', 'black hawk down':'Black Hawk Down','la la land':'La La Land','chicago':'Chicago', 'grease':'Grease','dirty dancing':'Dirty Dancing','west side story':'West Side Story', 'the sound of music':'The Sound of Music','my fair lady':'My Fair Lady', 'a star is born':'A Star Is Born','bohemian rhapsody':'Bohemian Rhapsody', 'rocketman':'Rocketman','walk the line':'Walk the Line', 'the blind side':'The Blind Side','remember the titans':'Remember the Titans', 'rudy':'Rudy','hoosiers':'Hoosiers','field of dreams':'Field of Dreams', 'a league of their own':'A League of Their Own','rocky':'Rocky','creed':'Creed', 'les miserables':'Les Misérables' };
const TV_TITLES = { 'the sopranos':'The Sopranos','the wire':'The Wire', 'breaking bad':'Breaking Bad','better call saul':'Better Call Saul', 'the shield':'The Shield','the americans':'The Americans', 'deadwood':'Deadwood','the west wing':'The West Wing', 'the x-files':'The X-Files','twin peaks':'Twin Peaks', 'six feet under':'Six Feet Under','mad men':'Mad Men', 'band of brothers':'Band of Brothers','the pacific':'The Pacific', 'game of thrones':'Game of Thrones','house of the dragon':'House of the Dragon', 'the last of us':'The Last of Us','succession':'Succession','the crown':'The Crown', 'chernobyl':'Chernobyl','true detective':'True Detective','fargo':'Fargo', 'mindhunter':'Mindhunter','ozark':'Ozark','narcos':'Narcos', 'peaky blinders':'Peaky Blinders','boardwalk empire':'Boardwalk Empire', 'justified':'Justified','sons of anarchy':'Sons of Anarchy', 'the walking dead':'The Walking Dead','house of cards':'House of Cards','veep':'Veep', 'homeland':'Homeland','24':'24','lost':'Lost', 'battlestar galactica':'Battlestar Galactica', "the handmaid's tale":"The Handmaid's Tale",'mr. robot':'Mr. Robot', 'black mirror':'Black Mirror','stranger things':'Stranger Things', 'the haunting of hill house':'The Haunting of Hill House','dark':'Dark', 'money heist':'Money Heist','squid game':'Squid Game','yellowstone':'Yellowstone', '1883':'1883','1923':'1923','the mandalorian':'The Mandalorian','andor':'Andor', 'the bear':'The Bear','the white lotus':'The White Lotus','euphoria':'Euphoria', 'severance':'Severance','the boys':'The Boys','ted lasso':'Ted Lasso', "schitt's creek":"Schitt's Creek",'fleabag':'Fleabag','killing eve':'Killing Eve', 'making a murderer':'Making a Murderer','the jinx':'The Jinx', 'the dropout':'The Dropout','inventing anna':'Inventing Anna','dahmer':'Dahmer', 'maid':'Maid','mare of easttown':'Mare of Easttown', "the queen's gambit":"The Queen's Gambit",'midnight mass':'Midnight Mass', 'station eleven':'Station Eleven','sharp objects':'Sharp Objects', 'big little lies':'Big Little Lies','downton abbey':'Downton Abbey', 'yellowjackets':'Yellowjackets', 'only murders in the building':'Only Murders in the Building', 'abbott elementary':'Abbott Elementary','the good place':'The Good Place', 'brooklyn nine-nine':'Brooklyn Nine-Nine','parks and recreation':'Parks and Recreation', 'the office':'The Office','arrested development':'Arrested Development', 'curb your enthusiasm':'Curb Your Enthusiasm','seinfeld':'Seinfeld','cheers':'Cheers', "m*a*s*h":'M*A*S*H','all in the family':'All in the Family','i love lucy':'I Love Lucy', 'the twilight zone':'The Twilight Zone','the brady bunch':'The Brady Bunch', 'happy days':'Happy Days','the cosby show':'The Cosby Show','friends':'Friends', "that '70s show":"That '70s Show",'the simpsons':'The Simpsons', 'family guy':'Family Guy','futurama':'Futurama','south park':'South Park', 'king of the hill':'King of the Hill','archer':'Archer', "bob's burgers":"Bob's Burgers",'rick and morty':'Rick and Morty', 'bojack horseman':'BoJack Horseman', 'avatar the last airbender':'Avatar: The Last Airbender', 'the legend of korra':'The Legend of Korra','attack on titan':'Attack on Titan', 'death note':'Death Note', 'fullmetal alchemist brotherhood':'Fullmetal Alchemist: Brotherhood', 'law and order':'Law and Order', 'law and order special victims unit':'Law and Order: Special Victims Unit', "grey's anatomy":"Grey's Anatomy",'er':'ER', 'how i met your mother':'How I Met Your Mother','sex and the city':'Sex and the City', 'the marvelous mrs. maisel':'The Marvelous Mrs. Maisel', 'the morning show':'The Morning Show','billions':'Billions','suits':'Suits', 'this is us':'This Is Us','the big bang theory':'The Big Bang Theory', 'two and a half men':'Two and a Half Men','malcolm in the middle':'Malcolm in the Middle' };
const ANIMAL_BREEDS = { 'affenpinscher':'affenpinscher','afghan hound':'Afghan hound','afghan':'Afghan', 'airedale terrier':'Airedale terrier','airedale':'Airedale','akita':'Akita', 'alaskan malamute':'Alaskan Malamute', 'american english coonhound':'American English coonhound', 'american eskimo dog':'American Eskimo dog','american foxhound':'American foxhound', 'american staffordshire terrier':'American Staffordshire terrier', 'american water spaniel':'American water spaniel', 'anatolian shepherd dog':'Anatolian shepherd dog', 'anatolian shepherd':'Anatolian shepherd', 'australian cattle dog':'Australian cattle dog', 'australian shepherd':'Australian shepherd','australian terrier':'Australian terrier', 'basenji':'basenji','basset hound':'basset hound','beagle':'beagle', 'bearded collie':'bearded collie','beauceron':'Beauceron', 'bedlington terrier':'Bedlington terrier','belgian malinois':'Belgian Malinois', 'belgian sheepdog':'Belgian sheepdog','belgian tervuren':'Belgian Tervuren', 'bernese mountain dog':'Bernese mountain dog','bichon frise':'bichon frise', 'black russian terrier':'Black Russian terrier', 'black and tan coonhound':'black and tan coonhound','bloodhound':'bloodhound', 'blue lacy':'Blue Lacy','bluetick coonhound':'bluetick coonhound', 'border collie':'Border collie','border terrier':'Border terrier','borzoi':'borzoi', 'boston terrier':'Boston terrier','bouvier des flandres':'Bouvier des Flandres', 'boxer':'boxer','boykin spaniel':'Boykin spaniel','bracco italiano':'Bracco Italiano', 'briard':'Briard','brittany':'Brittany','brussels griffon':'Brussels griffon', 'bull terrier':'bull terrier','bulldog':'bulldog','bullmastiff':'bullmastiff', 'cairn terrier':'cairn terrier','canaan dog':'Canaan dog','cane corso':'cane corso', 'cardigan welsh corgi':'Cardigan Welsh corgi', 'cavalier king charles spaniel':'Cavalier King Charles spaniel', 'cesky terrier':'Cesky terrier', 'chesapeake bay retriever':'Chesapeake Bay retriever','chihuahua':'Chihuahua', 'chinese crested':'Chinese crested','chinese shar pei':'Chinese Shar Pei', 'chinook':'Chinook','chow chow':'chow chow','clumber spaniel':'Clumber spaniel', 'cocker spaniel':'cocker spaniel','collie':'collie', 'curly coated retriever':'curly coated retriever','dachshund':'dachshund', 'dalmatian':'Dalmatian','dandie dinmont terrier':'Dandie Dinmont terrier', 'doberman pinscher':'Doberman pinscher','doberman':'Doberman', 'dogue de bordeaux':'Dogue de Bordeaux', 'english cocker spaniel':'English cocker spaniel', 'english foxhound':'English foxhound','english setter':'English setter', 'english sheepdog':'English sheepdog', 'english springer spaniel':'English springer spaniel', 'english toy spaniel':'English toy spaniel', 'entlebucher mountain dog':'Entlebucher mountain dog', 'field spaniel':'field spaniel','finnish lapphund':'Finnish lapphund', 'finnish spitz':'Finnish spitz','flat coated retriever':'flat coated retriever', 'french bulldog':'French bulldog','german pinscher':'German pinscher', 'german shepherd dog':'German shepherd dog','german shepherd':'German shepherd', 'german shorthaired pointer':'German shorthaired pointer', 'german wirehaired pointer':'German wirehaired pointer', 'giant schnauzer':'giant schnauzer','glen of imaal terrier':'Glen of Imaal terrier', 'golden retriever':'golden retriever','gordon setter':'Gordon setter', 'great dane':'Great Dane','great pyrenees':'Great Pyrenees', 'greater swiss mountain dog':'Greater Swiss mountain dog','greyhound':'greyhound', 'harrier':'harrier','havanese':'Havanese','ibizan hound':'Ibizan hound', 'icelandic sheepdog':'Icelandic sheepdog', 'irish red and white setter':'Irish red and white setter', 'irish setter':'Irish setter','irish terrier':'Irish terrier', 'irish water spaniel':'Irish water spaniel','irish wolfhound':'Irish wolfhound', 'italian greyhound':'Italian greyhound','jack russell terrier':'Jack Russell terrier', 'japanese chin':'Japanese Chin','keeshond':'Keeshond', 'kerry blue terrier':'Kerry blue terrier','komondor':'Komondor','kuvasz':'Kuvasz', 'labrador retriever':'Labrador retriever','labrador':'Labrador', 'lakeland terrier':'Lakeland terrier','leonberger':'Leonberger', 'lhasa apso':'Lhasa apso','lowchen':'lowchen','maltese':'Maltese', 'manchester terrier':'Manchester terrier','mastiff':'mastiff', 'miniature bull terrier':'miniature bull terrier', 'miniature pinscher':'miniature pinscher','miniature schnauzer':'miniature schnauzer', 'miniature australian shepherd':'Miniature Australian shepherd', 'neapolitan mastiff':'Neapolitan mastiff','newfoundland':'Newfoundland', 'norfolk terrier':'Norfolk terrier','norwegian buhund':'Norwegian buhund', 'norwegian elkhound':'Norwegian elkhound','norwegian lundehund':'Norwegian lundehund', 'norwich terrier':'Norwich terrier', 'nova scotia duck tolling retriever':'Nova Scotia duck tolling retriever', 'old english sheepdog':'Old English sheepdog','otterhound':'otterhound', 'papillon':'papillon','parson russell terrier':'Parson Russell terrier', 'pekingese':'Pekingese','pembroke welsh corgi':'Pembroke Welsh corgi', 'petit basset griffon vendeen':'Petit Basset Griffon Vendeen', 'pharaoh hound':'pharaoh hound','plott':'Plott','pointer':'pointer', 'polish lowland sheepdog':'Polish Lowland sheepdog','pomeranian':'Pomeranian', 'poodle':'poodle','portuguese water dog':'Portuguese water dog', 'pug':'pug','puli':'puli','pyrenean shepherd':'Pyrenean shepherd', 'redbone coonhound':'redbone coonhound','rhodesian ridgeback':'Rhodesian ridgeback', 'rottweiler':'Rottweiler','russell terrier':'Russell terrier','saluki':'Saluki', 'samoyed':'Samoyed','schipperke':'schipperke', 'scottish deerhound':'Scottish deerhound','scottish terrier':'Scottish terrier', 'scottie':'Scottie','sealyham terrier':'Sealyham terrier', 'shetland sheepdog':'Shetland sheepdog','shiba inu':'shiba inu','shih tzu':'shih tzu', 'siberian husky':'Siberian husky','silky terrier':'silky terrier', 'skye terrier':'Skye terrier','smooth fox terrier':'smooth fox terrier', 'soft coated wheaten terrier':'Soft Coated Wheaten terrier', 'spinone italiano':'Spinone Italiano','st. bernard':'St. Bernard', 'staffordshire bull terrier':'Staffordshire bull terrier', 'standard schnauzer':'standard schnauzer','sussex spaniel':'Sussex spaniel', 'swedish vallhund':'Swedish vallhund','tibetan mastiff':'Tibetan mastiff', 'tibetan spaniel':'Tibetan spaniel','tibetan terrier':'Tibetan terrier', 'toy fox terrier':'toy fox terrier', 'treeing walker coonhound':'treeing walker coonhound','vizsla':'vizsla', 'weimaraner':'Weimaraner','welsh springer spaniel':'Welsh springer spaniel', 'welsh terrier':'Welsh terrier', 'west highland white terrier':'West Highland white terrier','westie':'Westie', 'whippet':'whippet','wire fox terrier':'wire fox terrier', 'xoloitzcuintli':'Xoloitzcuintli','yorkshire terrier':'Yorkshire terrier','yorkie':'Yorkie', 'abyssinian':'Abyssinian','american shorthair':'American shorthair', 'american bobtail':'American bobtail','american curl':'American curl', 'balinese':'Balinese','bengal':'Bengal','birman':'Birman','bombay':'Bombay', 'british longhair':'British longhair','british shorthair':'British shorthair', 'burmese':'Burmese','burmilla':'Burmilla','chartreux':'Chartreux', 'cornish rex':'Cornish rex','devon rex':'Devon rex','egyptian mau':'Egyptian mau', 'european shorthair':'European shorthair','himalayan':'Himalayan', 'japanese bobtail':'Japanese bobtail','javanese':'Javanese','korat':'Korat', 'maine coon':'Maine coon','manx':'Manx','norwegian forest cat':'Norwegian forest cat', 'persian':'Persian','ragdoll':'Ragdoll','russian blue':'Russian blue', 'scottish fold':'Scottish fold','siamese':'Siamese','siberian cat':'Siberian cat', 'somali cat':'Somali cat','sphynx':'Sphynx','tonkinese':'Tonkinese', 'turkish angora':'Turkish Angora','turkish van':'Turkish Van', 'akhal teke':'Akhal Teke','andalusian':'Andalusian','appaloosa':'Appaloosa', 'arabian':'Arabian','ardennes':'Ardennes','clydesdale':'Clydesdale', 'friesian':'Friesian','hanoverian':'Hanoverian','lipizzaner':'Lipizzaner', 'morgan horse':'Morgan horse','mustang':'mustang','oldenburg':'Oldenburg', 'paint horse':'paint horse','palomino':'palomino','percheron':'Percheron', 'quarter horse':'quarter horse','shetland pony':'Shetland pony', 'shire horse':'shire horse','standardbred':'standardbred', 'tennessee walking horse':'Tennessee walking horse','thoroughbred':'thoroughbred', 'trakehner':'Trakehner','welsh mountain pony':'Welsh mountain pony', 'welsh pony':'Welsh pony','angus':'Angus','ayrshire':'Ayrshire', 'belted galloway':'Belted Galloway','brahman':'Brahman','brown swiss':'Brown Swiss', 'charolais':'Charolais','guernsey':'Guernsey','hereford':'Hereford', 'highland cattle':'Highland cattle','holstein':'Holstein','jersey':'Jersey', 'limousin':'Limousin','longhorn':'longhorn','simmental':'Simmental', 'texas longhorn':'Texas longhorn','border leicester':'Border Leicester', 'cheviot':'Cheviot','corriedale':'Corriedale','cotswold':'Cotswold','dorper':'Dorper', 'dorset':'Dorset','finnsheep':'Finnsheep','hampshire sheep':'Hampshire sheep', 'icelandic sheep':'Icelandic sheep','karakul':'Karakul','katahdin':'Katahdin', 'lincoln sheep':'Lincoln sheep','merino':'merino','navajo churro':'Navajo Churro', 'rambouillet':'Rambouillet','suffolk sheep':'Suffolk sheep', 'alpine goat':'Alpine goat','angora goat':'Angora goat','boer goat':'boer goat', 'nigerian dwarf':'Nigerian dwarf','nubian goat':'Nubian goat','oberhasli':'Oberhasli', 'pygmy goat':'pygmy goat','saanen':'Saanen','toggenburg':'Toggenburg', 'ancona chicken':'Ancona chicken','araucana':'Araucana','australorp':'Australorp', 'barnevelder':'Barnevelder','brahma chicken':'Brahma chicken', 'buckeye chicken':'Buckeye chicken','chantecler':'Chantecler', 'cornish chicken':'Cornish chicken','cubalaya':'Cubalaya','dorking':'Dorking', 'dutch bantam':'Dutch Bantam','faverolles':'Faverolles', 'hamburg chicken':'Hamburg chicken','houdan':'Houdan','jersey giant':'Jersey giant', 'leghorn':'leghorn','malay chicken':'Malay chicken','marans':'Marans', 'minorca chicken':'Minorca chicken','new hampshire red':'New Hampshire red', 'old english game':'Old English game','orpington':'Orpington', 'plymouth rock':'Plymouth Rock','rhode island red':'Rhode Island red', 'sussex chicken':'Sussex chicken','welsummer':'Welsummer','wyandotte':'Wyandotte', 'cayuga duck':'Cayuga duck','khaki campbell':'Khaki Campbell', 'muscovy duck':'muscovy duck','pekin duck':'Pekin duck', 'pomeranian duck':'Pomeranian duck','african goose':'African goose', 'chinese goose':'Chinese goose','embden goose':'Embden goose', 'toulouse goose':'Toulouse goose','bourbon red turkey':'Bourbon red turkey', 'narragansett turkey':'Narragansett turkey' };
const MONTHS = ['january','february','march','april','may','june','july','august','september','october','november','december']; const DAYS = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday']; const HOLIDAYS = ['christmas','easter','halloween','thanksgiving','independence day','memorial day','labor day','veterans day','new year\'s day','new year','presidents day','martin luther king day','columbus day','hanukkah','ramadan','kwanzaa','passover']; const RELIGIONS = ['christianity','islam','judaism','buddhism','hinduism','catholic','protestant','muslim','jewish','christian','hindu','buddhist']; const LANGUAGES = ['english','spanish','french','german','italian','chinese','japanese','russian','arabic','portuguese','korean','dutch','swedish','norwegian','danish','finnish','polish','greek','latin','hebrew']; const MILITARY_TITLES = ['captain','colonel','general','sergeant','lieutenant','major','admiral','commander','corporal','private','ensign']; const PROF_TITLES = ['doctor','professor','president','senator','representative','judge','mayor','governor','secretary','ambassador','minister','chancellor']; const RELIGIOUS_TITLES = ['pope','cardinal','bishop','archbishop','reverend','pastor','deacon','priest','rabbi','imam','chaplain','monsignor','vicar','parson','preacher','apostle','saint','st.']; const FAMILY_TITLES = ['aunt','uncle','grandmother','grandfather','mom','dad','mother','father','grandma','grandpa','cousin'];
let mode = 'standard'; function setMode(m) { mode = m; document.querySelectorAll('.mode-btn').forEach(b => b.classList.remove('active')); event.target.classList.add('active'); }
function process() { const txt = document.getElementById('input').value; if (!txt.trim()) { alert('Enter text first'); return; } const p = mode === 'standard' ? stdCap(txt) : titleCap(txt); show(p.text, p.changes); }
function applyDatabaseWithPlurals(r, c, db, label) { const entries = Object.entries(db).sort((a, b) => b[0].length - a[0].length); for (const [k, v] of entries) { const escaped = k.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const re = new RegExp('(? { const suf = suffix || ''; const result = v + suf; if (m.toLowerCase() !== result.toLowerCase()) { c.push({ b: m, a: result, r: label }); } return result; }); } return r; }
function applyDatabase(r, c, db, label) { const entries = Object.entries(db).sort((a, b) => b[0].length - a[0].length); for (const [k, v] of entries) { const escaped = k.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const re = new RegExp('(? { if (m !== v) c.push({ b: m, a: v, r: label }); return v; }); } return r; }
function stdCap(text) { let r = text; const c = [];
r = applyDatabase(r, c, MONUMENTS, 'Proper noun'); r = applyDatabase(r, c, GEO_REGIONS, 'Geographic region/neighborhood'); r = applyDatabase(r, c, US_STATES, 'US state'); r = applyDatabase(r, c, CANADIAN_PROVINCES, 'Canadian province');
const RECOGNIZED_DIRECTIONAL = new Set([ 'south florida','east texas','west texas','north texas','central texas', 'southern california','northern california','central california','eastern california', 'eastern kentucky','south chicago','south philadelphia','south philly', 'south boston','south bronx','north hollywood', 'east los angeles','west los angeles','north vancouver', 'northern virginia','eastern shore','upstate new york', 'northern ireland','western australia','south australia', 'northern territory','new south wales','western sahara', 'north africa','south africa','east africa','west africa', 'southern europe','eastern europe','western europe', 'middle east','far east','east asia','southeast asia', 'south pacific','north atlantic','south atlantic', 'eastern caribbean','western caribbean','central america', 'eastern bloc','western bloc','eastern seaboard', 'western hemisphere','northern hemisphere','southern hemisphere', 'new england','pacific northwest','great plains','gulf coast', 'mountain west','corn belt','rust belt','bible belt','sun belt' ]);
const dirPattern = /\b(Southern|Northern|Eastern|Western|Central|North|South|East|West)\s+(Alabama|Alaska|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusetts|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming|Alberta|British Columbia|Manitoba|New Brunswick|Newfoundland|Nova Scotia|Ontario|Quebec|Saskatchewan|Yukon)\b/g; r = r.replace(dirPattern, (m) => { if (RECOGNIZED_DIRECTIONAL.has(m.toLowerCase())) return m; const lc = m.charAt(0).toLowerCase() + m.slice(1); c.push({ b: m, a: lc, r: 'Directional description — lowercase' }); return lc; });
r = applyDatabase(r, c, BOOK_TITLES, 'Book title'); r = applyDatabase(r, c, MOVIE_TITLES, 'Movie title'); r = applyDatabase(r, c, TV_TITLES, 'TV show title'); r = applyDatabaseWithPlurals(r, c, ANIMAL_BREEDS, 'Animal breed');
MONTHS.forEach(month => { const cap = month.charAt(0).toUpperCase() + month.slice(1); const re = new RegExp('\\b' + month + '\\b', 'gi'); r = r.replace(re, (m) => { if (m !== cap) c.push({ b: m, a: cap, r: 'Month' }); return cap; }); });
DAYS.forEach(day => { const cap = day.charAt(0).toUpperCase() + day.slice(1); const re = new RegExp('\\b' + day + '\\b', 'gi'); r = r.replace(re, (m) => { if (m !== cap) c.push({ b: m, a: cap, r: 'Day of week' }); return cap; }); });
HOLIDAYS.forEach(holiday => { const cap = holiday.split(' ').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '); const re = new RegExp('\\b' + holiday.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '\\b', 'gi'); r = r.replace(re, (m) => { if (m !== cap) c.push({ b: m, a: cap, r: 'Holiday' }); return cap; }); });
RELIGIONS.forEach(rel => { const cap = rel.charAt(0).toUpperCase() + rel.slice(1); const re = new RegExp('\\b' + rel + '\\b', 'gi'); r = r.replace(re, (m) => { if (m !== cap) c.push({ b: m, a: cap, r: 'Religion' }); return cap; }); });
LANGUAGES.forEach(lang => { const cap = lang.charAt(0).toUpperCase() + lang.slice(1); const re = new RegExp('\\b' + lang + '\\b', 'gi'); r = r.replace(re, (m) => { if (m !== cap) c.push({ b: m, a: cap, r: 'Language' }); return cap; }); });
MILITARY_TITLES.forEach(title => { const cap = title.split(' ').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '); const re = new RegExp('\\b' + title.replace(/\s+/g, '\\s+') + '\\s+([A-Z][a-z]+)', 'gi'); r = r.replace(re, (m, name) => { const result = cap + ' ' + name; if (m !== result) c.push({ b: m, a: result, r: 'Military title before name' }); return result; }); });
PROF_TITLES.forEach(title => { const cap = title.split(' ').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '); const re = new RegExp('\\b' + title.replace(/\s+/g, '\\s+') + '\\s+([A-Z][a-z]+)', 'gi'); r = r.replace(re, (m, name) => { const result = cap + ' ' + name; if (m !== result) c.push({ b: m, a: result, r: 'Title before name' }); return result; }); });
r = r.replace(/\b(Bachelor'?s?|Master'?s?|Doctoral|Associate'?s?)\s+(Degree\b)/gi, (m, deg, word) => { const result = deg.toLowerCase() + ' ' + word.toLowerCase(); if (m !== result) c.push({ b: m, a: result, r: 'Generic degree reference — lowercase' }); return result; }); r = r.replace(/\b(bachelor'?s?|master'?s?|doctoral|associate'?s?)\s+degree\b/gi, (m) => { const result = m.toLowerCase(); if (m !== result) c.push({ b: m, a: result, r: 'Generic degree reference — lowercase' }); return result; }); r = r.replace(/\b(a|my|his|her|their|your|our)\s+(Bachelor'?s?|Master'?s?|Doctoral|Associate'?s?)\b/gi, (m, art, deg) => { const result = art.toLowerCase() + ' ' + deg.toLowerCase(); if (m !== result) c.push({ b: m, a: result, r: 'Generic degree reference — lowercase' }); return result; }); r = r.replace(/\bMasters\b(?!')/g, (m) => { c.push({ b: m, a: "master's", r: "Degree name needs apostrophe — master's" }); return "master's"; }); r = r.replace(/\bmasters\b(?!')/g, (m) => { c.push({ b: m, a: "master's", r: "Degree name needs apostrophe — master's" }); return "master's"; });
const fieldsOfStudy = ['economics','business','history','philosophy','psychology','sociology','mathematics','biology','chemistry','physics','english','literature','political science','computer science','engineering','nursing','accounting','finance','marketing','communications','journalism','education','law','medicine','theology']; fieldsOfStudy.forEach(field => { const cap = field.split(' ').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '); const re = new RegExp('\\b(in|of)\\s+' + cap + '\\b', 'g'); r = r.replace(re, (m, prep) => { const result = prep + ' ' + field; if (m !== result) c.push({ b: m, a: result, r: 'Field of study after "in/of" — lowercase' }); return result; }); });
r = r.replace(/\bvice\s+president\s+([A-Z][a-z]+)/gi, (m, name) => { const result = 'Vice President ' + name; if (m !== result) c.push({ b: m, a: result, r: 'Title before name' }); return result; }); r = r.replace(/\bVice\s+President\b(?!\s+[A-Z])/g, (m) => { c.push({ b: m, a: 'vice president', r: 'Title not before name — lowercase' }); return 'vice president'; }); r = r.replace(/\bformer\s+presidents?\b/gi, (m) => { const lc = m.toLowerCase(); if (m !== lc) c.push({ b: m, a: lc, r: 'Title not before name — lowercase' }); return lc; });
RELIGIOUS_TITLES.forEach(title => { const cap = title.charAt(0).toUpperCase() + title.slice(1); const re = new RegExp('\\b' + title.replace('.', '\\.') + '\\s+([A-Z][a-z]+)', 'gi'); r = r.replace(re, (m, name) => { const result = cap + ' ' + name; if (m !== result) c.push({ b: m, a: result, r: 'Religious title before name' }); return result; }); });
FAMILY_TITLES.forEach(title => { const cap = title.charAt(0).toUpperCase() + title.slice(1); const re1 = new RegExp('\\b' + title + '\\s+([A-Z][a-z]+)', 'gi'); r = r.replace(re1, (m, name) => { const result = cap + ' ' + name; if (m !== result) c.push({ b: m, a: result, r: 'Family title before name' }); return result; }); const re2 = new RegExp('\\b(my|your|his|her|their|our)\\s+' + cap + '\\b', 'gi'); r = r.replace(re2, (m, poss) => { const result = poss + ' ' + title; if (m !== result) c.push({ b: m, a: result, r: 'Family title after possessive' }); return result; }); });
r = r.replace(/\b(his|her|my|your|their|our)\s+(Pop-Pop|Grandpa|Grandma|Nana|Mimi|Pops|Papa)\b/gi, (m, poss, title) => { const result = poss + ' ' + title.toLowerCase(); if (m !== result) c.push({ b: m, a: result, r: 'Informal family title after possessive' }); return result; });
const rooms = ['Green Room','Blue Room','Red Room','Yellow Room','Oval Office','Rose Garden','East Room','West Wing']; rooms.forEach(rm => { const re = new RegExp('\\b' + rm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '\\b', 'gi'); r = r.replace(re, (m) => { if (m !== rm) c.push({ b: m, a: rm, r: 'Named room' }); return rm; }); });
const placeTypes = ['hall','office','garden','park','square','plaza','bridge','building','tower','center','hospital','school','university','college','library','museum','theater','theatre','stadium','arena','airport','station']; placeTypes.forEach(t => { const re = new RegExp('\\b([A-Z][a-z]+(?:\\s+[A-Z][a-z]+)*)\\s+(' + t + ')\\b', 'g'); r = r.replace(re, (m, n, rm) => { const cap = n + ' ' + rm.charAt(0).toUpperCase() + rm.slice(1); if (m !== cap) c.push({ b: m, a: cap, r: 'Named place' }); return cap; }); });
const streetTypes = ['street','avenue','boulevard','lane','way','place','court']; const numberWords = ['first','second','third','fourth','fifth','sixth','seventh','eighth','ninth','tenth','eleventh','twelfth','thirteenth','fourteenth','fifteenth','sixteenth','seventeenth','eighteenth','nineteenth','twentieth']; numberWords.forEach(num => { streetTypes.forEach(type => { const re = new RegExp('\\b' + num + '\\s+' + type + '\\b', 'gi'); const cap = num.charAt(0).toUpperCase() + num.slice(1) + ' ' + type.charAt(0).toUpperCase() + type.slice(1); r = r.replace(re, (m) => { if (m !== cap) c.push({ b: m, a: cap, r: 'Numbered street' }); return cap; }); }); }); streetTypes.forEach(type => { const re = new RegExp('\\b(\\d+(?:st|nd|rd|th))\\s+' + type + '\\b', 'gi'); r = r.replace(re, (m, num) => { const cap = num + ' ' + type.charAt(0).toUpperCase() + type.slice(1); if (m !== cap) c.push({ b: m, a: cap, r: 'Numbered street' }); return cap; }); });
r = r.replace(/(^|[.!?]\s+)([a-z])/g, (m, p, l) => { c.push({ b: p + l, a: p + l.toUpperCase(), r: 'Sentence start' }); return p + l.toUpperCase(); });
return { text: r, changes: c }; }
function titleCap(text) { const c = []; const low = new Set(['a','an','and','as','at','but','by','for','in','nor','of','on','or','out','so','the','to','up','yet','from','with','into','onto','upon','over','via']); let r = text;
for (const db of [BOOK_TITLES, MOVIE_TITLES, TV_TITLES]) { const entries = Object.entries(db).sort((a, b) => b[0].length - a[0].length); for (const [k, v] of entries) { const escaped = k.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const re = new RegExp('(? { if (m !== v) c.push({ b: m, a: v, r: 'Known title' }); return v; }); } }
const tokens = r.split(/(\s+)/); const wordTokens = tokens.filter(t => !/^\s+$/.test(t)); let wIdx = 0; const result = tokens.map(token => { if (/^\s+$/.test(token)) return token; const w = token; const cl = w.toLowerCase(); const pos = wIdx++;
if (MONUMENTS[cl]) return MONUMENTS[cl]; if (GEO_REGIONS[cl]) return GEO_REGIONS[cl]; if (US_STATES[cl]) return US_STATES[cl]; if (CANADIAN_PROVINCES[cl]) return CANADIAN_PROVINCES[cl];
const isFirst = pos === 0; const isLast = pos === wordTokens.length - 1;
if (isFirst || isLast) { const cap = w.charAt(0).toUpperCase() + w.slice(1).toLowerCase(); if (w !== cap) c.push({ b: w, a: cap, r: isFirst ? 'First word' : 'Last word' }); return cap; } if (low.has(cl)) { if (w !== cl) c.push({ b: w, a: cl, r: 'Short word — lowercase' }); return cl; } const cap = w.charAt(0).toUpperCase() + w.slice(1).toLowerCase(); if (w !== cap) c.push({ b: w, a: cap, r: 'Major word' }); return cap; });
return { text: result.join(''), changes: c }; }
function show(text, changes) { document.getElementById('result').textContent = text; const list = document.getElementById('changes'); if (changes.length > 0) { list.innerHTML = '
' + changes.length + ' change' + (changes.length !== 1 ? 's' : '') + ' made:
';
changes.forEach(ch => {
const d = document.createElement('div');
d.className = 'change';
d.innerHTML = '' + ch.b + ' → ' + ch.a + '
' + ch.r + '';
list.appendChild(d);
});
} else {
list.innerHTML = '
No changes needed
'; } document.getElementById('output').classList.add('show'); }
function copy() { const t = document.getElementById('result').textContent; navigator.clipboard.writeText(t).then(() => { const b = event.target; const o = b.textContent; b.textContent = 'Copied'; setTimeout(() => { b.textContent = o; }, 2000); }); }
function clearText() {
document.getElementById('input').value = '';
document.getElementById('output').classList.remove('show');
}