PHPackages                             ergebnis/composer-normalize - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ergebnis/composer-normalize

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

ergebnis/composer-normalize
===========================

Provides a composer plugin for normalizing composer.json.

2.50.0(3mo ago)1.1k37.3M—7.8%36[11 issues](https://github.com/ergebnis/composer-normalize/issues)20MITPHPPHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Jan 14Pushed 3d ago11 watchersCompare

[ Source](https://github.com/ergebnis/composer-normalize)[ Packagist](https://packagist.org/packages/ergebnis/composer-normalize)[ Docs](https://github.com/ergebnis/composer-normalize)[ RSS](/packages/ergebnis-composer-normalize/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (21)Versions (115)Used By (20)

composer-normalize
==================

[](#composer-normalize)

[![Integrate](https://github.com/ergebnis/composer-normalize/actions/workflows/integrate.yaml/badge.svg?branch=main)](https://github.com/ergebnis/composer-normalize/actions/workflows/integrate.yaml)[![Merge](https://github.com/ergebnis/composer-normalize/actions/workflows/merge.yaml/badge.svg)](https://github.com/ergebnis/composer-normalize/actions/workflows/merge.yaml)[![Release](https://github.com/ergebnis/composer-normalize/actions/workflows/release.yaml/badge.svg)](https://github.com/ergebnis/composer-normalize/actions/workflows/release.yaml)[![Renew](https://github.com/ergebnis/composer-normalize/actions/workflows/renew.yaml/badge.svg)](https://github.com/ergebnis/composer-normalize/actions/workflows/renew.yaml)

[![Code Coverage](https://camo.githubusercontent.com/4441d73ea780d1068b1222ee9d0079464eb377265fc72cc472fcea59b8a681c0/68747470733a2f2f636f6465636f762e696f2f67682f65726765626e69732f636f6d706f7365722d6e6f726d616c697a652f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/ergebnis/composer-normalize)

[![Latest Stable Version](https://camo.githubusercontent.com/04889a852d6b5a0d9678771d0effd1dceb761916944a0b722bb26d48fda30187/68747470733a2f2f706f7365722e707567782e6f72672f65726765626e69732f636f6d706f7365722d6e6f726d616c697a652f762f737461626c65)](https://packagist.org/packages/ergebnis/composer-normalize)[![Total Downloads](https://camo.githubusercontent.com/a75011a11b7cefe03dba583ad5ba9d8ccb7e27deabfb612e79d8a753203a450d/68747470733a2f2f706f7365722e707567782e6f72672f65726765626e69732f636f6d706f7365722d6e6f726d616c697a652f646f776e6c6f616473)](https://packagist.org/packages/ergebnis/composer-normalize)[![Monthly Downloads](https://camo.githubusercontent.com/5ed8b414ba27ea18dc9dc840ee0d2028fe0a1f5413a63a1ad741659d2456b418/687474703a2f2f706f7365722e707567782e6f72672f65726765626e69732f636f6d706f7365722d6e6f726d616c697a652f642f6d6f6e74686c79)](https://packagist.org/packages/ergebnis/composer-normalize)

This project provides a [`composer`](https://getcomposer.org) plugin for normalizing [`composer.json`](https://getcomposer.org/doc/04-schema.md).

[![Hmm, kinda cool I guess](https://user-images.githubusercontent.com/605483/150120621-1eb65e19-b924-481c-a9e5-e762f1f3cfc9.png)](https://github.com/laravel/laravel/pull/4856#issuecomment-439705243)

Why
---

[](#why)

When it comes to formatting `composer.json`, you have the following options:

- you can format it manually (and request changes when contributors format it differently)
- you can stop caring
- or you can use `ergebnis/composer-normalize`

`ergebnis/composer-normalize` normalizes `composer.json`, so you don't have to.

💡 If you want to find out more, take a look at the [examples](#examples) and read this [blog post](https://localheinz.com/blog/2018/01/15/normalizing-composer.json/).

Installation
------------

[](#installation)

### Composer

[](#composer)

Run

```
composer require --dev ergebnis/composer-normalize
```

to install `ergebnis/composer-normalize` as a composer plugin.

Run

```
composer config allow-plugins.ergebnis/composer-normalize true
```

to allow `ergebnis/composer-normalize` to run as a composer plugin.

💡 The `allow-plugins` has been added to `composer/composer` to add an extra layer of security.

For reference, see

- [composer/composer#10314](https://github.com/composer/composer/pull/10314)
-

### Phar

[](#phar)

Head over to  and download the latest `composer-normalize.phar`.

Run

```
chmod +x composer-normalize.phar
```

to make the downloaded `composer-normalize.phar` executable.

### Phive

[](#phive)

Run

```
phive install ergebnis/composer-normalize
```

to install `ergebnis/composer-normalize` with [PHIVE](https://phar.io).

Usage
-----

[](#usage)

### Composer

[](#composer-1)

Run

```
composer normalize
```

to normalize `composer.json` in the working directory.

### Phar

[](#phar-1)

Run

```
./composer-normalize.phar
```

to normalize `composer.json` in the working directory.

### Phive

[](#phive-1)

Run

```
./tools/composer-normalize
```

to normalize `composer.json` in the working directory.

### Details

[](#details)

The `NormalizeCommand` provided by the `NormalizePlugin` within this package will

- determine whether a `composer.json` exists
- determine whether a `composer.lock` exists, and if so, whether it is up to date (unless the `--no-check-lock` option is used)
- use [`Ergebnis\Json\Normalizer\Vendor\Composer\ComposerJsonNormalizer`](https://github.com/ergebnis/json-normalizer#vendorcomposercomposerjsonnormalizer) to normalize the content of `composer.json`
- format the normalized content (either as sniffed, or as specified using the `--indent-size` and `--indent-style` options)
- write the normalized and formatted content of `composer.json` back to the file
- update the hash in `composer.lock` if it exists and if an update is necessary

### Arguments

[](#arguments)

- `file`: Path to `composer.json` file (optional, defaults to `composer.json` in working directory)

### Options

[](#options)

- `--diff`: Show the results of normalizing
- `--dry-run`: Show the results of normalizing, but do not modify any files
- `--indent-size`: Indent size (an integer greater than 0); should be used with the `--indent-style` option
- `--indent-style`: Indent style (one of "space", "tab"); should be used with the `--indent-size` option
- `--no-check-lock`: Do not check if lock file is up to date
- `--no-update-lock`: Do not update lock file if it exists

As an alternative to specifying the `--indent-size` and `--indent-style` options, you can also use composer [extra](https://getcomposer.org/doc/04-schema.md#extra) to configure these options in `composer.json`:

```
{
  "extra": {
    "composer-normalize": {
      "indent-size": 2,
      "indent-style": "space"
    }
  }
}
```

💡 The configuration provided in composer extra always overrides the configuration provided via command line options.

### Continuous Integration

[](#continuous-integration)

If you want to run this in continuous integration services, use the `--dry-run` option.

```
composer normalize --dry-run
```

In case `composer.json` is not normalized (or `composer.lock` is not up-to-date), the command will fail with an exit code of `1` and show a diff.

Examples
--------

[](#examples)

### `pestphp/pest`

[](#pestphppest)

Running

```
composer normalize
```

against  yields the following diff:

```
diff --git a/composer.json b/composer.json
index 1cfbf1e..204f20f 100644
--- a/composer.json
+++ b/composer.json
@@ -25,6 +25,32 @@
         "pestphp/pest-plugin-init": "^0.3",
         "phpunit/phpunit": ">= 9.3.7 =7.3",
         "ext-dom": "*",
@@ -54,20 +50,22 @@
         "ext-PDO": "*",
         "phpspec/prophecy-phpunit": "^2.0.1"
     },
+    "suggest": {
+        "ext-soap": "*",
+        "ext-xdebug": "*"
+    },
     "config": {
+        "optimize-autoloader": true,
         "platform": {
             "php": "7.3.0"
         },
-        "optimize-autoloader": true,
         "sort-packages": true
     },
-    "suggest": {
-        "ext-soap": "*",
-        "ext-xdebug": "*"
+    "extra": {
+        "branch-alias": {
+            "dev-master": "9.5-dev"
+        }
     },
-    "bin": [
-        "phpunit"
-    ],
     "autoload": {
         "classmap": [
             "src/"
@@ -86,9 +84,11 @@
             "tests/_files/NamespaceCoveredFunction.php"
         ]
     },
-    "extra": {
-        "branch-alias": {
-            "dev-master": "9.5-dev"
-        }
+    "prefer-stable": true,
+    "bin": [
+        "phpunit"
+    ],
+    "support": {
+        "issues": "https://github.com/sebastianbergmann/phpunit/issues"
     }
 }
```

Changelog
---------

[](#changelog)

The maintainers of this project record notable changes to this project in a [changelog](CHANGELOG.md).

Contributing
------------

[](#contributing)

The maintainers of this project suggest following the [contribution guide](.github/CONTRIBUTING.md).

Code of Conduct
---------------

[](#code-of-conduct)

The maintainers of this project ask contributors to follow the [code of conduct](https://github.com/ergebnis/.github/blob/main/CODE_OF_CONDUCT.md).

General Support Policy
----------------------

[](#general-support-policy)

The maintainers of this project provide limited support.

You can support the maintenance of this project by [sponsoring @ergebnis](https://github.com/sponsors/ergebnis).

PHP Version Support Policy
--------------------------

[](#php-version-support-policy)

This project currently supports the following PHP versions:

- [PHP 7.4](https://www.php.net/releases/#7.4.0) (has reached its end of life on November 28, 2022)
- [PHP 8.0](https://www.php.net/releases/#8.0.0) (has reached its end of life on November 26, 2023)
- [PHP 8.1](https://www.php.net/releases/#8.1.0) (has reached its end of life on December 31, 2025)
- [PHP 8.2](https://www.php.net/releases/#8.2.0)
- [PHP 8.3](https://www.php.net/releases/#8.3.0)
- [PHP 8.4](https://www.php.net/releases/#8.4.0)
- [PHP 8.5](https://www.php.net/releases/#8.5.0)

The maintainers of this project add support for a PHP version following its initial release and *may* drop support for a PHP version when it has reached its [end of life](https://www.php.net/supported-versions.php).

Security Policy
---------------

[](#security-policy)

This project has a [security policy](.github/SECURITY.md).

License
-------

[](#license)

This project uses the [MIT license](LICENSE.md).

Social
------

[](#social)

Follow [@localheinz](https://twitter.com/intent/follow?screen_name=localheinz) and [@ergebnis](https://twitter.com/intent/follow?screen_name=ergebnis) on Twitter.

###  Health Score

82

—

ExcellentBetter than 100% of packages

Maintenance91

Actively maintained with recent releases

Popularity72

Solid adoption and visibility

Community55

Growing community involvement

Maturity98

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~28 days

Recently: every ~41 days

Total

105

Last Release

98d ago

Major Versions

0.9.0 → 1.0.02018-11-17

1.3.1 → 2.0.02019-12-17

PHP version history (14 changes)0.1.0PHP ^7.0

0.3.0PHP ^7.1

2.0.0PHP ^7.2

2.6.0PHP ^7.1 || ^8.0

2.8.1PHP ^7.2 || ^8.0

2.20.0PHP ^7.3 || ^8.0

2.21.0PHP ^7.4 || ^8.0

2.29.0PHP ^8.0

2.30.0PHP ~8.0.0 || ~8.1.0 || ~8.2.0

2.32.0PHP ~8.1.0 || ~8.2.0

2.38.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

2.42.0PHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

2.44.0PHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

2.48.0PHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cabc9efd157e2b47aa5aa9830180f5ebd07813cc3e93ff1a9993b2c3d264909?d=identicon)[localheinz](/maintainers/localheinz)

---

Top Contributors

[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (1231 commits)")[![ergebnis-bot](https://avatars.githubusercontent.com/u/59560144?v=4)](https://github.com/ergebnis-bot "ergebnis-bot (837 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (786 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (188 commits)")[![eliashaeussler](https://avatars.githubusercontent.com/u/16313625?v=4)](https://github.com/eliashaeussler "eliashaeussler (3 commits)")[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (2 commits)")[![kubawerlos](https://avatars.githubusercontent.com/u/9282069?v=4)](https://github.com/kubawerlos "kubawerlos (2 commits)")[![mxr576](https://avatars.githubusercontent.com/u/1755573?v=4)](https://github.com/mxr576 "mxr576 (2 commits)")[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (2 commits)")[![andrey-helldar](https://avatars.githubusercontent.com/u/10347617?v=4)](https://github.com/andrey-helldar "andrey-helldar (1 commits)")[![TravisCarden](https://avatars.githubusercontent.com/u/959246?v=4)](https://github.com/TravisCarden "TravisCarden (1 commits)")[![ntwb](https://avatars.githubusercontent.com/u/1016458?v=4)](https://github.com/ntwb "ntwb (1 commits)")[![ravage84](https://avatars.githubusercontent.com/u/625761?v=4)](https://github.com/ravage84 "ravage84 (1 commits)")[![ruudk](https://avatars.githubusercontent.com/u/104180?v=4)](https://github.com/ruudk "ruudk (1 commits)")[![sfritzsche](https://avatars.githubusercontent.com/u/32567473?v=4)](https://github.com/sfritzsche "sfritzsche (1 commits)")[![spawnia](https://avatars.githubusercontent.com/u/12158000?v=4)](https://github.com/spawnia "spawnia (1 commits)")[![AlexSkrypnyk](https://avatars.githubusercontent.com/u/378794?v=4)](https://github.com/AlexSkrypnyk "AlexSkrypnyk (1 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (1 commits)")[![core23](https://avatars.githubusercontent.com/u/3440437?v=4)](https://github.com/core23 "core23 (1 commits)")[![keradus](https://avatars.githubusercontent.com/u/2716794?v=4)](https://github.com/keradus "keradus (1 commits)")

---

Tags

composercomposer-pluginjsonnormalizerplugincomposernormalizernormalize

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ergebnis-composer-normalize/health.svg)

```
[![Health](https://phpackages.com/badges/ergebnis-composer-normalize/health.svg)](https://phpackages.com/packages/ergebnis-composer-normalize)
```

###  Alternatives

[pyrech/composer-changelogs

Display changelogs after each composer update

5904.0M25](/packages/pyrech-composer-changelogs)[veewee/composer-run-parallel

Run composer tasks in parallel

91748.2k13](/packages/veewee-composer-run-parallel)[laminas/laminas-component-installer

Composer plugin for injecting modules and configuration providers into application configuration

294.1M95](/packages/laminas-laminas-component-installer)[netresearch/composer-patches-plugin

Composer patches plugin

80262.1k7](/packages/netresearch-composer-patches-plugin)[sllh/composer-lint

Extends the composer validate command with extra rules

14214.6k7](/packages/sllh-composer-lint)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
