PHP Toolkit

Format (PSR-2), minify, or validate PHP. Indent 2/4/8 spaces, remove comments. Upload .php, copy, download.

PHP Formatter
Quick presets:

Quick presets

Input PHP

0/500000 Words: 0

Output PHP

Format Options

What is PHP Toolkit?

PHP Toolkit is a free online tool that formats, minifies, and validates PHP code. In format mode, it beautifies messy or minified PHP by applying consistent indentation and line breaks. In minify mode, it removes whitespace and optionally comments to reduce file size for production. In validate mode, it checks PHP syntax and reports errors with line and column numbers. Developers use it to clean up code before commits, prepare assets for deployment, or debug syntax issues. The tool supports file upload, copy, and download. No account or signup is required.

The tool offers three modes: Format, Minify, and Validate. Format options include indent size (2, 4, or 8 spaces) and indent character (space or tab). Minify options include removing comments. Quick presets (Basic, Class, Minified) load sample code for testing. The status bar shows validation result (Valid/Invalid) and, in minify mode, original size, minified size, and savings percentage. Input and output appear in side-by-side panels on desktop and stacked on mobile. Upload supports .php, .phtml, .inc, and .txt files.

Who Benefits from This Tool

PHP developers benefit when cleaning up code from external sources or legacy projects. Paste minified or poorly formatted code, format it for readability, then copy back. Minify mode helps when preparing production assets where every byte counts. Validate mode catches syntax errors before running code.

Code reviewers and team leads benefit when enforcing style. Format the code to a standard indent and share. The tool does not replace a full linter or formatter (e.g., PHP-CS-Fixer) but provides quick fixes without local setup.

Learners and educators benefit when studying PHP. Format mode makes code easier to read. Validate mode helps identify common syntax mistakes. The sample presets demonstrate different code structures.

Key Features

Format Mode

Beautifies PHP with configurable indent (2, 4, or 8 spaces) and indent character (space or tab). Structures code for readability. Handles classes, functions, and control structures.

Minify Mode

Removes unnecessary whitespace and optionally comments. Reduces file size. Shows original size, minified size, and savings percentage. Useful for production deployment.

Validate Mode

Checks PHP syntax. Reports errors with line and column numbers and messages. Displays a success message when valid. Does not execute code; only parses it.

Quick Presets

Basic loads a simple PHP snippet. Class loads a sample class. Minified loads minified code for testing format or validate. Presets are available on desktop and mobile.

File Upload and Download

Upload .php, .phtml, .inc, or .txt files. Download the result as a file. Copy button copies output to clipboard.

How to Use

  1. Select mode. Choose Format, Minify, or Validate.
  2. Enter or upload PHP code. Paste into the input area or use the upload button to load a file.
  3. Set options. In format mode, choose indent size and character. In minify mode, toggle remove comments.
  4. Click the process button. Label changes by mode (Format PHP, Minify PHP, Validate PHP). Complete captcha if required.
  5. Copy or download. Use copy or download to save the result. In validate mode, review the validation message and any error details.

Common Use Cases

  • Formatting minified or messy PHP from third-party libraries
  • Minifying PHP before deployment to reduce size
  • Validating PHP syntax before running or committing
  • Cleaning up code copied from tutorials or forums
  • Preparing code for code review or documentation
  • Debugging syntax errors with line and column information

Tips & Best Practices

For format mode, choose an indent size that matches your project (often 4 spaces). Use tab if your team prefers tabs. Minify only for production; keep formatted source for development. Validate before deploying to catch syntax errors early.

Large files may take longer to process. The tool has a character limit; very large files may need to be split. Do not paste sensitive credentials; the tool may send code to a server for processing. Check the privacy policy.

Limitations & Notes

The tool parses PHP but does not execute it. It cannot detect logic errors or runtime issues. Validation is syntax-only. Format and minify rely on the parser's output; edge cases or invalid PHP may produce unexpected results. The tool does not store your code; process and copy in one session. File size limits apply to uploads.

FAQs

Is the tool free?

Yes. No signup required. A captcha may appear.

Does it execute my PHP code?

No. The tool only parses PHP for format, minify, and validate. Code is not run.

What PHP version does it support?

The parser typically supports a range of PHP versions. Very new syntax may not be fully supported. Check validation results for compatibility.

Can I minify and keep comments?

The minify option to remove comments can be toggled off. You will still get whitespace reduction.

Why does validation fail on valid code?

The parser may not support all PHP 8+ features or edge cases. Ensure the code is syntactically correct. Try formatting first to see if the parser accepts it.

Is minified PHP safe to use?

Minification only removes whitespace and optionally comments. It does not obfuscate or encrypt. Do not rely on it for security.

Can I format only part of a file?

The tool processes the full input. For partial formatting, you may need to paste the relevant section.

Does the tool support PHP short tags?

Support depends on the parser. Standard <?php is always supported. Short echo <?= may be supported.

What file types can I upload?

.php, .phtml, .inc, and .txt are accepted. The tool treats the content as PHP.

How large can my input be?

There is a character limit (e.g., 500000). Very large files may be rejected or slow.