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.3.0(2w ago)3957.8M↓24.9%60[1 issues](https://github.com/spatie/typescript-transformer/issues)[2 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 3d ago

READMEChangelog (10)Dependencies (55)Versions (48)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://github.com/spatie/typescript-transformer/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/typescript-transformer/actions/workflows/run-tests.yml)[![PHPStan](https://github.com/spatie/typescript-transformer/actions/workflows/phpstan.yml/badge.svg)](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

74

—

ExcellentBetter than 100% of packages

Maintenance95

Actively maintained with recent releases

Popularity67

Solid adoption and visibility

Community41

Growing community involvement

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 70.5% 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 ~24 days

Total

40

Last Release

15d 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 (420 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (31 commits)")[![AyoobMH](https://avatars.githubusercontent.com/u/37803924?v=4)](https://github.com/AyoobMH "AyoobMH (31 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)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (6 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![robertvansteen](https://avatars.githubusercontent.com/u/14931924?v=4)](https://github.com/robertvansteen "robertvansteen (6 commits)")[![jerodev](https://avatars.githubusercontent.com/u/3493941?v=4)](https://github.com/jerodev "jerodev (5 commits)")[![jaulz](https://avatars.githubusercontent.com/u/5358638?v=4)](https://github.com/jaulz "jaulz (5 commits)")[![ragulka](https://avatars.githubusercontent.com/u/593267?v=4)](https://github.com/ragulka "ragulka (3 commits)")[![jameshulse](https://avatars.githubusercontent.com/u/797280?v=4)](https://github.com/jameshulse "jameshulse (2 commits)")[![jimirobaer](https://avatars.githubusercontent.com/u/8984769?v=4)](https://github.com/jimirobaer "jimirobaer (2 commits)")[![adrum](https://avatars.githubusercontent.com/u/1464185?v=4)](https://github.com/adrum "adrum (2 commits)")[![Klaas058](https://avatars.githubusercontent.com/u/16153346?v=4)](https://github.com/Klaas058 "Klaas058 (2 commits)")[![badams](https://avatars.githubusercontent.com/u/340715?v=4)](https://github.com/badams "badams (2 commits)")[![nmu-bouharri](https://avatars.githubusercontent.com/u/171939819?v=4)](https://github.com/nmu-bouharri "nmu-bouharri (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

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

[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[deptrac/deptrac

Deptrac is a static code analysis tool that helps to enforce rules for dependencies between software layers.

3.0k8.8M118](/packages/deptrac-deptrac)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[jolicode/castor

A lightweight and modern task runner. Automate everything. In PHP.

54743.1k4](/packages/jolicode-castor)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136406.3k14](/packages/rector-rector-src)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M101](/packages/dedoc-scramble)

PHPackages © 2026

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