# CodeFormatter, one Sublime Text command that formats seven languages

> akalongman/sublimetext-codeformatter is a Sublime Text 2 and 3 plugin that exposes format and format-on-save for PHP, JavaScript, JSON, HTML, CSS, LESS, SASS, Go, Visual Basic and ColdFusion, with several formatters working under the hood. The PHP path needs a local PHP 5.6 or newer, the Go path needs gofmt, and the HTML path uses a forked BeautifulSoup.

**akalongman/sublimetext-codeformatter** — Code Formatter plugin for ST2/ST3

- Repository: https://github.com/akalongman/sublimetext-codeformatter
- Stars: 769 · Forks: 128
- Language: Python
- License: MIT
- Published: 2026-10-21 · Updated: 2026-10-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/akalongman-sublimetext-codeformatter

## The languages and the formatters behind them

CodeFormatter is a Sublime Text 2 and 3 plugin that supports formatting, or beautifying, source code, and the interesting part is that it is not one formatter wrapped in a plugin. Each language goes to a different tool.

PHP is handled by phpF, by subins2000. JavaScript and JSON go to JSBeautifier by Einar Lielmanis, and CSS, LESS and SASS share that same formatter. HTML uses a custom fork of BeautifulSoup maintained for this project. Go uses gofmt. Visual Basic and VBScript have their own support, as does ColdFusion with the Railo and Lucee variants.

That list tells you the plugin's real scope. It is a single command surface over a set of independent upstream tools, which means the quality of the output is the quality of whichever formatter owns that language, and the plugin's job is configuration, invocation and integration with Sublime's save and selection events.

The HTML case is the one worth singling out. Using a fork of BeautifulSoup means the HTML formatter is not the same as the stock library, and that fork is a maintenance commitment someone has to carry. The README credits the fork to the plugin's own repository rather than to BeautifulSoup upstream.

For Go, the choice of gofmt is not a stylistic preference but a correctness one, since gofmt output is what the Go toolchain and every linter expect.

## Installing it three different ways

The README gives three installation routes, and the choice between them is about how you want updates handled.

The easiest is Package Control, the Sublime Text package manager. You install Package Control, restart Sublime Text, open the Command Palette with Command+Shift+P on macOS or Control+Shift+P on Linux and Windows, choose Package Control: Install Package, wait while it fetches the package list, and pick CodeFormatter. The stated advantage is that Package Control keeps the plugin updated automatically.

Without Git, you download the latest source from GitHub and copy the CodeFormatter folder into your Sublime Text Packages directory.

With Git, you clone the repository into that same directory:

```bash
git clone https://github.com/akalongman/sublimetext-codeformatter.git CodeFormatter
```

The directory name in the clone command is CodeFormatter, which is what Sublime Text expects to find, since a package's folder name is how the plugin is identified.

The README then lists where Packages lives on each platform and for each Sublime version, which is the detail that trips people up. On macOS it is under Library/Application Support/Sublime Text 2 or 3 in the home directory. On Linux it is .config/sublime-text-2 or sublime-text-3 in the home directory. On Windows it is %APPDATA%/Sublime Text 2 or 3.

That the plugin still supports Sublime Text 2 is itself a fact about its age, and it means the same install works across both generations.

## The preferences file and how options are grouped

Configuration lives in a file called CodeFormatter - User Preferences, reachable from the Sublime Text menu bar under Sublime Text > Package Settings > CodeFormatter > Settings - User.

The README warns about the structure, and the warning is worth repeating: you must wrap all the configurations into a single root object. The shape is:

```js
{
   "codeformatter_php_options": {...},
   "codeformatter_js_options": {...},
   ..
}
```

Each language has its own options key, prefixed with codeformatter_ and suffixed with _options. The naming is consistent across the file, which is what lets the plugin look up the right block by syntax.

The PHP block shows how much control is offered. The syntaxes key names the Sublime syntax names the formatter applies to, and php_path points at a PHP executable, with an example given as /usr/lib/php or C:/Program Files/PHP/php.exe, and an empty value meaning the php command from the system environment is used.

format_on_save takes either a boolean or a regular expression tested against the filename, and the example given is a negative lookahead pattern that excludes .min. and vendor paths, which is the kind of thing you need to avoid formatting generated files.

The style options are the substance: psr1, psr1_naming, psr2, indent_with_space set to 4, enable_auto_align, visibility_order for the PSR-2 method ordering rule, and smart_linebreak_after_curly. Then passes and excludes let you enable or disable individual transformations by name, and there is a command palette entry that lists every available transformation.

## JavaScript options and the separate Python formatters

The JavaScript and JSON block shows the JSBeautifier options, and they are the standard set that tool exposes. indent_size, indent_char and indent_with_tabs control indentation, with indent_with_tabs overriding the other two. eol sets the line ending symbol and preserve_newlines with max_preserve_newlines controls whether existing line breaks survive.

There are also the options that change output in ways people argue about. space_in_paren pads inside parentheses, space_in_empty_paren does it in empty ones. brace_style offers collapse, expand and end-expand, which are the Allman and ANSI styles. keep_array_indentation and keep_function_indentation preserve the indentation of arrays and functions instead of normalising it. wrap_line_length with 0 meaning no wrapping.

The JavaScript options are the same family used by other JSBeautifier integrations, so a configuration here will look familiar to anyone who has used the tool elsewhere.

The Python side of the plugin is worth noting, because it is where the formatters actually live. The repository root has CodeFormatter.py as the entry point, a codeformatter/ directory holding the bundled formatter code including the PHP beautifier library and the BeautifulSoup fork, and the.sublime-commands,.sublime-settings and.sublime-menu files that define the Sublime integration.

The releases show this side being actively maintained against a moving Python. Version 4.3.4 isolates the bundled bs4, 4.3.3 fixes the bundled formatters on newer Python, and 4.3.2 fixes a Go format-on-save regular expression. The last push came two days after the 4.3.4 release, so this is an actively fixed project rather than an abandoned one.

## Where CodeFormatter sits and what it will not do

The comparison to make is with a language-specific tool, which is the most common setup people are leaving behind.

For a single language, a dedicated tool is better. A Prettier configuration with an ignore file, or a gofmt-only workflow, or an ESLint rule set with --fix gives you per-project configuration in the project's own repository, versioned with the code, rather than in a user-level settings file that applies to every file you open in the editor. That difference matters more than it sounds: a format-on-save rule that lives in the project is enforced for everyone who clones it, while a Sublime preference is enforced only on your machine.

CodeFormatter's advantage is coverage and convenience. One command works across seven language families, the options are tuned per language rather than per project, and the format-on-save regular expression lets you scope behaviour to a file path without a separate config file. For a developer who moves between languages and does not want to maintain several formatter configurations, that is the value.

The limitation follows from the design. There is no per-project configuration file. There is no way to say this repository uses four spaces and that one uses tabs, except by maintaining the settings in Sublime and switching them by hand. And because the underlying formatters are separate tools with their own release cycles, an upgrade of the plugin can change your output without you changing anything.

The PHP path has the extra operational burden. The README requires PHP 5.6 or above installed, points at the PHP manual for getting it, and notes that on Linux and macOS you must set the executable bit on fmt.phar in the plugin's lib directory after installation. That is the kind of step where a plugin silently does nothing until you notice.

## Conclusion

Adopt CodeFormatter if you edit several languages in Sublime Text and want a single consistent format-on-save behaviour, with per-language options you can tune. Skip it if you only ever format one language, since a language specific tool will do that better. Verify first by installing through Package Control, running the format command on a file in each language you care about, and confirming the PHP formatter works if you use it, because it needs PHP 5.6 or newer installed and marked executable separately.

## FAQ

### Which languages does the CodeFormatter Sublime Text plugin support?

PHP through phpF, JavaScript and JSON through JSBeautifier, HTML through a custom fork of BeautifulSoup, CSS, LESS and SASS also through JSBeautifier, Go through gofmt, plus Visual Basic and VBScript, and ColdFusion including the Railo and Lucee variants.

### How do I install CodeFormatter in Sublime Text?

The easiest route is Package Control: install Package Control, open the Command Palette, choose Package Control: Install Package and select CodeFormatter, which keeps it updated automatically. You can also clone the repository into your Packages directory as CodeFormatter with git clone, or copy the folder there by hand.

### Where do I configure CodeFormatter?

In the CodeFormatter - User Preferences file, reachable under Sublime Text > Package Settings > CodeFormatter > Settings - User. The README insists that all the configurations are wrapped into a single root object, with one codeformatter_<language>_options block per language.

### Does CodeFormatter need PHP installed for the PHP formatter?

Yes. The README requires PHP 5.6 or above, and on Linux and macOS you must set the executable permission on fmt.phar in the plugin's lib directory after installation, otherwise the PHP formatter will not run.

### Can CodeFormatter format on save?

Yes. Each language block has a format_on_save option that takes either a boolean or a regular expression tested against the filename, with the README giving a negative lookahead example that excludes .min. and vendor paths.

## Sources

- [akalongman/sublimetext-codeformatter on GitHub](https://github.com/akalongman/sublimetext-codeformatter)
- [Issues](https://github.com/akalongman/sublimetext-codeformatter/issues)
- [License: MIT](https://github.com/akalongman/sublimetext-codeformatter/blob/master/LICENSE)
- [README](https://github.com/akalongman/sublimetext-codeformatter/blob/master/README.md)
- [Releases](https://github.com/akalongman/sublimetext-codeformatter/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/akalongman-sublimetext-codeformatter
