Cette page n’est pas encore traduite en français : elle s’affiche en anglais.

PHP Formatter & Beautifier

Paste messy or minified PHP and get clean, consistently formatted code — indentation, braces, arrays and long argument lists laid out the same way every time.

Mis à jour le

Vos données ne quittent jamais votre ordinateur. Tout le traitement se fait localement dans votre navigateur.

Comment utiliser : PHP Formatter

  1. Paste your PHP code — with or without the opening <?php tag.
  2. Set line width, indentation and quote style.
  3. Copy or download the formatted code.

How the formatter works

The code is parsed into a syntax tree by Prettier’s PHP plugin and printed again from scratch, so the output is consistent regardless of how messy the input was — and the formatter never changes what the code does. Syntax errors are reported with the line, so it doubles as a quick PHP syntax check.

Style options

The defaults follow the common PSR-12 conventions: 4-space indentation and braces for classes and functions on their own line. Line width controls when long arrays and argument lists wrap onto multiple lines. Mixed PHP and HTML templates are supported.

Keep formatting automatic

For whole projects, use the same rules in your editor or CI with Prettier and @prettier/plugin-php, or with PHP-CS-Fixer for PSR-12. Formatting on save keeps diffs focused on real changes.

Private by design

Formatting runs entirely in your browser — your code is never uploaded, so it’s safe for proprietary projects.

Aussi recherché comme : php beautifier, format php code, php code formatter online, beautify php, php pretty print, psr-12 formatter.

Outils complémentaires : PHP Formatter

  • JavaScript Formatter — Unminify and pretty-print JavaScript, JSON or JSX with your preferred indentation and brace style — or strip whitespace and comments with a verified minifier.
  • HTML Formatter — Paste minified or messy markup and get clean, consistently indented HTML — including embedded <style> and <script> blocks.
  • SQL Formatter — Paste a query — or a whole migration — and get readable SQL with one clause per line, aligned joins and consistent keyword case, using the grammar of your database.
  • Formateur JSON — Collez votre code JSON pour le formater, le compresser ou le valider.

Questions fréquentes

Does the formatter change how my PHP runs?
No. It only changes whitespace, line breaks and quote style where that’s safe — the logic is untouched.
Which PHP versions are supported?
PHP 5 through 8.3 syntax, including attributes, enums, readonly properties, match expressions and named arguments.
Is it PSR-12 compliant?
The output follows PSR-12’s main rules for indentation and braces. For strict PSR-12 enforcement in a project, also run PHP-CS-Fixer.
Puis-je installer PHP Formatter en tant qu’application web et l’utiliser hors ligne ?
Oui. PHP Formatter est une application web installable (PWA) : elle s’installe depuis votre navigateur, sans passer par une boutique d’applications. Cliquez sur « Installer l’application » en haut de cette page dans Chrome ou Edge (Windows, macOS, Linux, ChromeOS) ; sur Android, utilisez « Partager » → « Ajouter à l’écran d’accueil » sur iPhone et iPad ; ou « Fichier » → « Ajouter au Dock » dans Safari 17+ sur Mac. L’application s’ouvre alors dans sa propre fenêtre avec sa propre icône, et comme elle s’exécute entièrement dans votre navigateur, elle continue de fonctionner hors ligne. Firefox sur ordinateur de bureau ne permet pas d’installer d’applications web. Comment fonctionne l’installation.

Outils similaires