{ Composer JSON Validator }

// validate composer.json syntax and structure instantly

Validate your composer.json file instantly in the browser. Checks JSON syntax, required fields, version constraints, license, and autoload configuration for free.

Paste the full contents of your composer.json file
// QUICK LOAD
🔍

Validation results appear here

Paste your composer.json and click Validate

HOW TO USE

  1. 01
    Paste your composer.json

    Copy the full contents of your composer.json file into the input area on the left.

  2. 02
    Click Validate

    Hit the Validate button or press Ctrl+Enter to run all checks instantly.

  3. 03
    Review results

    Errors, warnings, and notices are listed with field names and fix suggestions.

WHAT WE CHECK

JSON Syntax Required Fields Version Constraints PSR-4 Autoload License Field PHP Constraint Stability Flags Authors Format

USE CASES

  • 📦 Validate before publishing to Packagist
  • 🔧 Catch PSR-4 namespace errors early
  • 🛡️ Check wildcard "*" dependency risks
  • ⚡ Verify PHP version constraints

WHAT IS THIS?

Composer JSON Validator checks your composer.json file for syntax errors, missing required fields, and common configuration mistakes. It runs entirely in your browser — no files are sent to any server.

Whether you're publishing to Packagist or setting up a new PHP project, this tool helps you catch issues before they break your build or CI pipeline.

RELATED TOOLS

FREQUENTLY ASKED QUESTIONS

Is my composer.json sent to a server?

No. All validation runs entirely in your browser using JavaScript. Your code never leaves your machine — there is no server processing involved.

What does the "name" field format require?

The name field must follow the format vendor/package using lowercase letters, numbers, hyphens, underscores, or dots. Example: myvendor/my-package.

What is a valid version constraint?

Composer supports several formats: exact (1.0.2), range (>=1.0 <2.0), wildcard (1.0.*), tilde (~1.2), and caret (^1.2.3). The caret operator is recommended for most packages.

Why does my PSR-4 namespace show an error?

PSR-4 namespace keys must always end with a double backslash (\\). For example: "App\\": "src/". Missing the trailing backslash will cause autoloading to fail.

Should I set "minimum-stability" to dev?

Setting minimum-stability to dev lets you install development packages, but it can pull in unstable dependencies. Use it with "prefer-stable": true to minimize risk.

Does this tool validate all composer.json fields?

This tool validates the most important fields including name, description, require, license, autoload, authors, type, and minimum-stability. For the full spec, refer to the official Composer schema.

What is a Composer JSON Validator?

A Composer JSON Validator is a tool that checks the structure and contents of your composer.json file — the core configuration file for PHP projects that use Composer, the most widely used PHP dependency manager. A valid composer.json ensures Composer can correctly read your project's metadata, resolve dependencies, configure autoloading, and publish the package to Packagist if needed.

Even experienced PHP developers make subtle mistakes in composer.json: a missing trailing backslash in a PSR-4 namespace, a wildcard version constraint that pulls in breaking changes, or a missing license field that gets flagged by Packagist reviewers. This validator catches these issues instantly, before they cause a build failure or a failed publish attempt.

What Does composer.json Contain?

The composer.json file is a JSON document that Composer reads to understand your project. It includes fields like:

Common composer.json Mistakes

Even with good intentions, many developers ship composer.json files with subtle problems. Here are the most frequent issues this validator catches:

How PSR-4 Autoloading Works

PSR-4 (PHP Standard Recommendation 4) is a standard for autoloading PHP classes from the filesystem. It maps namespace prefixes to directory paths. For example:

"autoload": {
  "psr-4": {
    "App\\": "src/"
  }
}

This tells Composer that any class in the App\ namespace can be found in the src/ directory. The class App\Http\Controller would map to src/Http/Controller.php. The trailing double backslash in the namespace key is mandatory — without it, Composer cannot resolve the mapping correctly.

Understanding Version Constraints in Composer

Composer's version constraint system is one of its most powerful features, but also one of the easiest to misconfigure. The main formats are:

For libraries, the caret operator (^) is almost always the right choice because it follows semantic versioning: breaking changes only happen in major version bumps, and the caret ensures you get bug fixes and new features while staying protected from breaking changes.

Why Validate Before Publishing to Packagist?

Packagist, the default Composer package repository, performs its own validation when you submit or update a package. If your composer.json fails validation, the package update will be rejected, and your users may be left on an outdated version. Catching these issues locally — before pushing a tag to GitHub or GitLab — saves you time and protects your users from disruption.

Additionally, many CI/CD pipelines run composer validate as an early step. If your composer.json has issues, the entire build fails. Using this tool as a quick pre-commit sanity check can prevent unnecessary CI failures.

The Difference Between Errors, Warnings, and Notices

This validator reports three levels of issues to help you prioritize fixes:

A clean validation result — no errors, no warnings — is the baseline you should aim for before publishing any PHP package. This Composer JSON Validator helps you get there in seconds, entirely in your browser, for free.