PHPackages                             spatie/laravel-typescript-transformer - 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. spatie/laravel-typescript-transformer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

spatie/laravel-typescript-transformer
=====================================

Transform your PHP structures to TypeScript types

3.0.3(2mo ago)3736.0M—6.3%32[1 PRs](https://github.com/spatie/laravel-typescript-transformer/pulls)20MITPHPPHP ^8.2CI passing

Since Sep 2Pushed 2mo ago5 watchersCompare

[ Source](https://github.com/spatie/laravel-typescript-transformer)[ Packagist](https://packagist.org/packages/spatie/laravel-typescript-transformer)[ Docs](https://github.com/spatie/typescript-transformer)[ Fund](https://spatie.be/open-source/support-us)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-laravel-typescript-transformer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (27)Versions (33)Used By (20)

Transform PHP to TypeScript
===========================

[](#transform-php-to-typescript)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ee7f17bb6dbf094b9ce5daaaca9aa555597fa8a4d1f171309db727b28baaa193/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d747970657363726970742d7472616e73666f726d65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-typescript-transformer)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0a3e97c9e990140d76b65ab53f92859fecd4ac6dbfc99ec475d554b02e6f9103/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d747970657363726970742d7472616e73666f726d65722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-typescript-transformer/actions?query=workflow%3Arun-tests+branch%3Amaster)[![Styling](https://github.com/spatie/laravel-typescript-transformer/workflows/Check%20&%20fix%20styling/badge.svg)](https://github.com/spatie/laravel-typescript-transformer/actions?query=workflow%3A%22Check+%26+fix+styling%22)[![Total Downloads](https://camo.githubusercontent.com/35260161f7e9ff8fef1b61c3df4d4b5da8ece5310ac4407cf653f1f7fbb0f4f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d747970657363726970742d7472616e73666f726d65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-typescript-transformer)

This package allows you to convert PHP classes and more to TypeScript.

This class...

```
#[TypeScript]
class User
{
    public int $id;
    public string $name;
    public ?string $address;
}
```

... will be converted to this TypeScript type:

```
export type User = {
    id: number;
    name: string;
    address: string | null;
}
```

Here's another example.

```
enum Languages: string
{
    case TYPESCRIPT = 'typescript';
    case PHP = 'php';
}
```

The `Languages` enum will be converted to:

```
export type Languages = 'typescript' | 'php';
```

And that's just the beginning! TypeScript transformer can handle complex types, generics and even allows you to create TypeScript functions.

You can find the full documentation [here](https://spatie.be/docs/typescript-transformer/v3/introduction).

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Ruben Van Assche](https://github.com/rubenvanassche)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

71

—

ExcellentBetter than 100% of packages

Maintenance87

Actively maintained with recent releases

Popularity65

Solid adoption and visibility

Community40

Growing community involvement

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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

Every ~69 days

Recently: every ~4 days

Total

30

Last Release

63d ago

Major Versions

1.1.2 → 2.0.02021-04-08

2.5.2 → 3.0.0-beta.12026-01-16

2.6.0 → 3.0.02026-03-13

PHP version history (5 changes)1.0.0PHP ^7.4

1.1.1PHP ^7.4|^8.0

2.0.0PHP ^8.0

2.3.0PHP ^8.1

3.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (212 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (21 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (4 commits)")[![jimirobaer](https://avatars.githubusercontent.com/u/8984769?v=4)](https://github.com/jimirobaer "jimirobaer (3 commits)")[![innocenzi](https://avatars.githubusercontent.com/u/16060559?v=4)](https://github.com/innocenzi "innocenzi (3 commits)")[![Tofandel](https://avatars.githubusercontent.com/u/6115458?v=4)](https://github.com/Tofandel "Tofandel (2 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![AyoobMH](https://avatars.githubusercontent.com/u/37803924?v=4)](https://github.com/AyoobMH "AyoobMH (2 commits)")[![badams](https://avatars.githubusercontent.com/u/340715?v=4)](https://github.com/badams "badams (2 commits)")[![njoguamos](https://avatars.githubusercontent.com/u/29255728?v=4)](https://github.com/njoguamos "njoguamos (2 commits)")[![scottbedard](https://avatars.githubusercontent.com/u/7980426?v=4)](https://github.com/scottbedard "scottbedard (2 commits)")[![dominosaurs](https://avatars.githubusercontent.com/u/19289785?v=4)](https://github.com/dominosaurs "dominosaurs (1 commits)")[![DaxServer](https://avatars.githubusercontent.com/u/7479937?v=4)](https://github.com/DaxServer "DaxServer (1 commits)")[![bram-pkg](https://avatars.githubusercontent.com/u/13304739?v=4)](https://github.com/bram-pkg "bram-pkg (1 commits)")[![kenan-recebli](https://avatars.githubusercontent.com/u/13809906?v=4)](https://github.com/kenan-recebli "kenan-recebli (1 commits)")[![menthol](https://avatars.githubusercontent.com/u/1001497?v=4)](https://github.com/menthol "menthol (1 commits)")[![bensherred](https://avatars.githubusercontent.com/u/22666637?v=4)](https://github.com/bensherred "bensherred (1 commits)")[![rasmuscnielsen](https://avatars.githubusercontent.com/u/8465957?v=4)](https://github.com/rasmuscnielsen "rasmuscnielsen (1 commits)")[![Bloemendaal](https://avatars.githubusercontent.com/u/1348606?v=4)](https://github.com/Bloemendaal "Bloemendaal (1 commits)")[![ekateiva](https://avatars.githubusercontent.com/u/12799259?v=4)](https://github.com/ekateiva "ekateiva (1 commits)")

---

Tags

spatietypescript-transformer

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spatie-laravel-typescript-transformer/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-typescript-transformer/health.svg)](https://phpackages.com/packages/spatie-laravel-typescript-transformer)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-health

Monitor the health of a Laravel application

86910.0M83](/packages/spatie-laravel-health)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[spatie/laravel-schedule-monitor

Monitor scheduled tasks in a Laravel app

9815.7M9](/packages/spatie-laravel-schedule-monitor)

PHPackages © 2026

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