Advertisements

headerup to 320x100 / 728x90

PHP Code Viewer

Read and pretty-print PHP source with brace-balanced indentation and syntax highlighting

Input
Loading editor...
Output

Output will appear here...

Advertisements

content bottomup to 300x250

What is PHP Code Viewer

Last reviewed:

PHP is a server-side scripting language that powers a large share of the web, including platforms like WordPress, Drupal, and Laravel-based applications.

PHP Code Viewer is a quick-look tool for PHP classes, functions, and scripts. It re-indents your code with balanced braces and renders it with syntax highlighting.

It runs entirely in the browser, so you can safely inspect proprietary PHP code without sharing it with a server.

Why use it

  • Quickly review PHP snippets before sharing.
  • Re-indent copy-pasted code from logs.
  • Share readable code with teammates.
  • Audit generated PHP output.
  • Teach PHP syntax with clean examples.

Features

  • Brace-aware re-indentation
  • PHP syntax highlighting
  • PHP parsed locally in your browser
  • Respects HEREDOC / NOWDOC
  • Fast copy-paste

How to use PHP Code Viewer

  1. Paste PHP. Drop any PHP source.
  2. Click Run. See it re-indented and highlighted.
  3. Copy. Paste into your doc or IDE.

Example (before/after)

Raw

<?php function hi($n){echo "Hi $n";}hi("Ada");

Formatted

<?php
function hi($n) {
  echo "Hi $n";
}
hi("Ada");

Common errors

HEREDOC / NOWDOC

Multi-line string literals are preserved verbatim.

Fix: No action needed — indentation respects string boundaries.

Mixed HTML

PHP templates with HTML are re-indented by braces only.

Fix: Use an HTML formatter for the HTML portions.

FAQ

Does it execute the code?

No — this is a pretty-printer only.

Is source uploaded?

No — processing is client-side.

Does it format PHPDoc blocks?

Yes — they're preserved with their original line breaks.

Which PHP versions are supported?

All — input is treated as text.

Difference vs PHP Beautifier?

Beautifier has deeper formatting; the Viewer is fast re-indent.