PHPackages                             specdocular/laravel-rules-to-schema - 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. [API Development](/categories/api)
4. /
5. specdocular/laravel-rules-to-schema

ActiveLibrary[API Development](/categories/api)

specdocular/laravel-rules-to-schema
===================================

Convert Laravel validation rules to JSON Schema

v0.1.0(3mo ago)0373↓50%MITPHPPHP ^8.2CI passing

Since Feb 13Pushed 2mo agoCompare

[ Source](https://github.com/specdocular/laravel-rules-to-schema)[ Packagist](https://packagist.org/packages/specdocular/laravel-rules-to-schema)[ Docs](https://github.com/specdocular/laravel-rules-to-schema)[ RSS](/packages/specdocular-laravel-rules-to-schema/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (15)Versions (2)Used By (0)

Laravel Rules to Schema
=======================

[](#laravel-rules-to-schema)

[![Latest Version on Packagist](https://camo.githubusercontent.com/540322fa19162384a36332c83f4acad3e7de6a070c1c4980610aa26cead4fe19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73706563646f63756c61722f6c61726176656c2d72756c65732d746f2d736368656d612e737667)](https://packagist.org/packages/specdocular/laravel-rules-to-schema)[![PHP Version](https://camo.githubusercontent.com/c04e75947de3cfd8ff90f1b30bc955c5ecbc5b69a2a1c71c657a41bdceada93a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73706563646f63756c61722f6c61726176656c2d72756c65732d746f2d736368656d612e737667)](https://packagist.org/packages/specdocular/laravel-rules-to-schema)[![Tests](https://github.com/specdocular/laravel-rules-to-schema/actions/workflows/tests.yml/badge.svg)](https://github.com/specdocular/laravel-rules-to-schema/actions/workflows/tests.yml)[![codecov](https://camo.githubusercontent.com/16bac11944115e5f069843dd7d78eb68265140f0dd364d87e504e44effd16985/68747470733a2f2f636f6465636f762e696f2f67682f73706563646f63756c61722f6c61726176656c2d72756c65732d746f2d736368656d612f67726170682f62616467652e737667)](https://codecov.io/gh/specdocular/laravel-rules-to-schema)[![Code Style](https://github.com/specdocular/laravel-rules-to-schema/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/specdocular/laravel-rules-to-schema/actions/workflows/php-cs-fixer.yml)

Convert Laravel validation rules into [JSON Schema Draft 2020-12](https://json-schema.org/draft/2020-12/json-schema-core) definitions.

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

[](#installation)

```
composer require specdocular/laravel-rules-to-schema
```

The service provider is auto-discovered by Laravel.

Usage
-----

[](#usage)

```
use Specdocular\LaravelRulesToSchema\RuleToSchema;
use Specdocular\LaravelRulesToSchema\ValidationRuleNormalizer;

$converter = app(RuleToSchema::class);

$rules = [
    'email' => ['required', 'email', 'max:255'],
    'age' => ['required', 'integer', 'min:18', 'max:120'],
    'tags' => ['array'],
    'tags.*' => ['string', 'max:50'],
];

$normalizer = new ValidationRuleNormalizer();
$normalized = $normalizer->normalize($rules);

$schema = $converter->transform($normalized);
$compiled = $schema->compile();
```

### Configuration

[](#configuration)

Publish the config file to customize rule parsers:

```
php artisan vendor:publish --tag=rules-to-schema-config
```

Features
--------

[](#features)

- Converts 25+ built-in Laravel validation rules to JSON Schema
- Handles nested objects, arrays, and wildcard (`*`) rules
- Supports conditional rules (`required_if`, `required_with`, etc.)
- Extensible — register custom rule parsers via config
- Auto-registered as a Laravel service provider

Related Packages
----------------

[](#related-packages)

PackageDescription[specdocular/php-json-schema](https://github.com/specdocular/php-json-schema)JSON Schema Draft 2020-12 builder (foundation)[specdocular/php-openapi](https://github.com/specdocular/php-openapi)Object-oriented OpenAPI builder[specdocular/laravel-openapi](https://github.com/specdocular/laravel-openapi)Laravel integration for OpenAPI generationLicense
-------

[](#license)

MIT. See [LICENSE](LICENSE) for details.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance83

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Unknown

Total

1

Last Release

95d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e05ce3549156452319c5fdfc014b5eb441e3a6148f1f4957fb863026ecc6f8a0?d=identicon)[mohammad-alavi](/maintainers/mohammad-alavi)

---

Top Contributors

[![Mohammad-Alavi](https://avatars.githubusercontent.com/u/24431504?v=4)](https://github.com/Mohammad-Alavi "Mohammad-Alavi (11 commits)")

---

Tags

laravelvalidationjson-schemaopenapi

###  Code Quality

TestsPest

Static AnalysisPHPStan, Psalm, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/specdocular-laravel-rules-to-schema/health.svg)

```
[![Health](https://phpackages.com/badges/specdocular-laravel-rules-to-schema/health.svg)](https://phpackages.com/packages/specdocular-laravel-rules-to-schema)
```

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[wotz/laravel-swagger-ui

Add Swagger UI to a Laravel application.

277321.8k](/packages/wotz-laravel-swagger-ui)[kirschbaum-development/laravel-openapi-validator

Automatic OpenAPI validation for Laravel HTTP tests

581.1M5](/packages/kirschbaum-development-laravel-openapi-validator)

PHPackages © 2026

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