r/javascript • u/neikiri • May 01 '26
I made a free browser-based code formatter that handles HTML, CSS, JavaScript, PHP and JSON all at once - with auto-detection [Open Source]
neiki.euHey everyone,
I have been working on a side project called Polyglot Formatter. It's an open-source code beautifier that runs entirely in the browser and can format HTML, CSS, JavaScript, PHP and JSON all in one place. You just paste your code, it auto-detects the language and formats it with one click. There is no install, no signup, no backend - everything is client-side.
It also handles things like nested style and script blocks inside HTML, mixed PHP/HTML files, and JSON pretty-printing. The editor uses CodeMirror and the output is syntax-highlighted with Prism.js. It has a dark theme, configurable indentation, line wrapping options, and a responsive layout that works on mobile too.
Live version: https://neiki.eu/polyglot-formatter
GitHub: https://github.com/neikiri/polyglot-formatter
Now I want to be completely honest.. The formatter still has quite a few bugs. Building a tool that reliably formats five different languages including all the possible nested combinations of HTML inside PHP inside JavaScript and so on, turned out to be way harder than I expected when I started. I genuinely had no idea how complex this problem is and I'm still working through a lot of edge cases.
So if you try it out and run into any broken formatting, weird output or unexpected behavior, I would really appreciate it if you could report it on the GitHub issues page at https://github.com/neikiri/polyglot-formatter/issues. I would prefer bug reports there rather than in comments or DMs so I can actually track and fix them properly.
Every report helps a lot. Thanks for checking it out and any feedback is welcome :)