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

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

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

This is my package typescript-transformer

3.1.1(2mo ago)3706.5M—4.5%53[1 issues](https://github.com/spatie/typescript-transformer/issues)[3 PRs](https://github.com/spatie/typescript-transformer/pulls)11MITPHPPHP ^8.2CI passing

Since Sep 2Pushed 1mo ago5 watchersCompare

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

READMEChangelog (10)Dependencies (27)Versions (41)Used By (11)

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

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/3adf23f3f82911e8d82f68293a3ad721384f2219718805b22d82de5b77988a80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f747970657363726970742d7472616e73666f726d65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/typescript-transformer)[![Tests](https://camo.githubusercontent.com/ddd662b203201ee9da9f2ec65c367e180962ebecf0013ef45062b347d57d8081/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f747970657363726970742d7472616e73666f726d65722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/spatie/typescript-transformer/actions/workflows/run-tests.yml)[![PHPStan](https://camo.githubusercontent.com/d737224d73c959908d1f530441e9b2d3b6187e8296383de6880c60885e9c2a38/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f747970657363726970742d7472616e73666f726d65722f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/spatie/typescript-transformer/actions/workflows/phpstan.yml)[![Total Downloads](https://camo.githubusercontent.com/75c64115e2c9ce1d2ebab6cb2681b7306d5dcea3a3b44ce4b083c876eb033e04/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f747970657363726970742d7472616e73666f726d65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/typescript-transformer)

This package allows you to convert PHP classes &amp; 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).

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/98c95267a564a4251301e3eae4d7f117211e8d2a46c3cf140528d27864fb50e5/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f747970657363726970742d7472616e73666f726d65722e6a70673f743d31)](https://spatie.be/github-ad-click/typescript-transformer)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require spatie/typescript-transformer
```

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 Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

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

Maintenance89

Actively maintained with recent releases

Popularity65

Solid adoption and visibility

Community39

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 71.3% 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 ~54 days

Recently: every ~15 days

Total

38

Last Release

61d ago

Major Versions

0.0.1 → 1.0.02020-09-02

v1.x-dev → 2.0.02021-04-08

v2.x-dev → 3.0.0-beta.12026-01-16

PHP version history (5 changes)0.0.1PHP ^7.4

1.1.1PHP ^7.4|^8.0

2.0.0PHP ^8.0

2.5.0PHP ^8.1

3.0.0-beta.1PHP ^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 (417 commits)")[![AyoobMH](https://avatars.githubusercontent.com/u/37803924?v=4)](https://github.com/AyoobMH "AyoobMH (31 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (29 commits)")[![innocenzi](https://avatars.githubusercontent.com/u/16060559?v=4)](https://github.com/innocenzi "innocenzi (18 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (14 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (12 commits)")[![erikgaal](https://avatars.githubusercontent.com/u/1234268?v=4)](https://github.com/erikgaal "erikgaal (11 commits)")[![robertvansteen](https://avatars.githubusercontent.com/u/14931924?v=4)](https://github.com/robertvansteen "robertvansteen (6 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (6 commits)")[![jaulz](https://avatars.githubusercontent.com/u/5358638?v=4)](https://github.com/jaulz "jaulz (5 commits)")[![jerodev](https://avatars.githubusercontent.com/u/3493941?v=4)](https://github.com/jerodev "jerodev (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![nmu-bouharri](https://avatars.githubusercontent.com/u/171939819?v=4)](https://github.com/nmu-bouharri "nmu-bouharri (2 commits)")[![jameshulse](https://avatars.githubusercontent.com/u/797280?v=4)](https://github.com/jameshulse "jameshulse (2 commits)")[![ragulka](https://avatars.githubusercontent.com/u/593267?v=4)](https://github.com/ragulka "ragulka (2 commits)")[![badams](https://avatars.githubusercontent.com/u/340715?v=4)](https://github.com/badams "badams (2 commits)")[![adrum](https://avatars.githubusercontent.com/u/1464185?v=4)](https://github.com/adrum "adrum (2 commits)")[![jimirobaer](https://avatars.githubusercontent.com/u/8984769?v=4)](https://github.com/jimirobaer "jimirobaer (2 commits)")[![Klaas058](https://avatars.githubusercontent.com/u/16153346?v=4)](https://github.com/Klaas058 "Klaas058 (2 commits)")[![Mosaab-Emam](https://avatars.githubusercontent.com/u/26435307?v=4)](https://github.com/Mosaab-Emam "Mosaab-Emam (1 commits)")

---

Tags

spatietypescript-transformer

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[phpdocumentor/reflection-docblock

With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.

9.4k722.2M1.2k](/packages/phpdocumentor-reflection-docblock)[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M568](/packages/symfony-maker-bundle)[spatie/laravel-data

Create unified resources and data transfer objects

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

Store your application settings

1.5k5.9M72](/packages/spatie-laravel-settings)[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5953.3M56](/packages/roave-backward-compatibility-check)[spatie/laravel-typescript-transformer

Transform your PHP structures to TypeScript types

3736.0M45](/packages/spatie-laravel-typescript-transformer)

PHPackages © 2026

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