PHPackages                             locutusjs/locutus - 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. locutusjs/locutus

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

locutusjs/locutus
=================

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

v3.0.34(1mo ago)3.8k31.1kMITTypeScriptPHP &gt;=8.0CI failing

Since Jan 7Pushed 1mo ago194 watchersCompare

[ Source](https://github.com/locutusjs/locutus)[ Packagist](https://packagist.org/packages/locutusjs/locutus)[ Docs](https://locutus.io)[ RSS](/packages/locutusjs-locutus/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (50)Used By (0)

Locutus
=======

[](#locutus)

[![CI](https://github.com/locutusjs/locutus/actions/workflows/ci.yml/badge.svg)](https://github.com/locutusjs/locutus/actions/workflows/ci.yml)[![npm version](https://camo.githubusercontent.com/1091202612962790854fc6660d5e5e38a0ad32b408f29f70d4cebdb932e1ec56/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f6c6f63757475732e737667)](https://www.npmjs.com/package/locutus)[![Verified: PHP 8.3](https://camo.githubusercontent.com/feeaac2f2310ad733dfa5ef3f7a818579e9031de883e5ee4e40a7eb862f605c9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657269666965642d504850253230382e332d3737374242342e737667)](https://locutus.io/php/)[![Verified: Python 3.12](https://camo.githubusercontent.com/8bd3cd3019b33e76e267d4e397af443a0657fbfae72e5bf622593e2ca940ca85/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657269666965642d507974686f6e253230332e31322d3337373641422e737667)](https://locutus.io/python/)

> All your standard libraries will be assimilated into our JavaScript TypeScript collective. Resistance is futile.

Locutus is ~500 TypeScript implementations of standard library functions from PHP, Go, Python, Ruby, C, and [more](https://locutus.io/). Each function is individually importable and tree-shakeable.

Most of these started as rainy Sunday afternoon puzzles. Some are genuinely useful. Some are just fun to write. All of them are a way to learn how different languages solve the same problems.

Scope
-----

[](#scope)

Locutus ports function behavior, not foreign runtime baggage. We reimplement standard-library semantics in TypeScript, but keep API boundaries JavaScript-native.

That means we do not recreate alien language data structures or object models in Locutus APIs (for example: Go slices/maps, Python tuples/bytes, Ruby symbols, C structs/pointers, Perl refs).

Historic exception: for PHP compatibility, plain JS objects may be treated as associative arrays when `locutus.objectsAsArrays` is enabled.

Example: a Go date-formatting port in Locutus should accept a JavaScript `Date` and return a `string`, not a custom Go `time.Time` object.

Install
-------

[](#install)

```
npm install locutus
```

Locutus uses pragmatic versioning: `patch` is the default even for function-level parity fixes; see `CONTRIBUTING.md#versioning` for exact bump criteria.

Use
---

[](#use)

```
import { sprintf } from 'locutus/php/strings/sprintf'

const effectiveness = 'futile'
console.log(sprintf('Resistance is %s', effectiveness))
// Resistance is futile
```

```
import { Contains } from 'locutus/golang/strings/Contains'

console.log(Contains('Locutus', 'cut'))
// true
```

Bundle Size
-----------

[](#bundle-size)

For bundle-sensitive browser builds, prefer per-function deep imports over category index imports.

Good:

```
import { sprintf } from 'locutus/php/strings/sprintf'
```

Avoid in browser bundles:

```
import { sprintf } from 'locutus/php/strings/index'
```

Why:

- deep imports only pull the function you asked for and its real dependencies
- category index imports can force bundlers to traverse many unrelated exports in the same namespace
- this matters most in prebundled UMD/browser artifacts where downstream tree-shaking cannot recover later

If you are publishing your own browser bundle on top of Locutus, treat deep imports as the default.

Browser Compatibility (Copy-Paste Snippets)
-------------------------------------------

[](#browser-compatibility-copy-paste-snippets)

Code shown on function pages (`Module JS` / `Standalone JS`) targets:

- `baseline widely available with downstream`

Package runtime targets:

- Node: `engines.node >= 22`
- Published dist output (`dist/` CommonJS + `dist/esm` ESM): `ES2022`

If your application targets older browsers, treat Locutus snippets like normal application code:

1. transpile to your target (for example with TypeScript, Babel, SWC, or esbuild)
2. add required polyfills for missing APIs in your environment
3. validate with your own Browserslist target and browser test matrix

Locutus does not inject polyfills into copy-paste snippets by default.

Development
-----------

[](#development)

Some guidelines and instructions can be found in [CONTRIBUTING.md](CONTRIBUTING.md)

Quick commands:

- `yarn check` - format + lint + test
- `yarn test:parity` - cross-language verification
- `yarn test` - full test suite
- `yarn lint` - Biome check
- `yarn fix:biome` - auto-fix

License
-------

[](#license)

MIT, except for `src/php/bc/` and `src/php/_helpers/_bc.js` which are LGPL-2.1 (derived from PHP's bcmath/Libbcmath). See [LICENSE](LICENSE) for details.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance91

Actively maintained with recent releases

Popularity35

Limited adoption so far

Community39

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% 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 ~2 days

Total

41

Last Release

42d ago

Major Versions

v2.0.39 → v3.0.02026-03-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/50c8cdff5461214c7149cd8f1c55473b144ef0c3740a79e2d78eb9f2a1cfa4bc?d=identicon)[vardumper](/maintainers/vardumper)

---

Top Contributors

[![kvz](https://avatars.githubusercontent.com/u/26752?v=4)](https://github.com/kvz "kvz (1516 commits)")[![brettz9](https://avatars.githubusercontent.com/u/20234?v=4)](https://github.com/brettz9 "brettz9 (851 commits)")[![kukawski](https://avatars.githubusercontent.com/u/346655?v=4)](https://github.com/kukawski "kukawski (104 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (49 commits)")[![theriault](https://avatars.githubusercontent.com/u/150607?v=4)](https://github.com/theriault "theriault (20 commits)")[![onnomarsman](https://avatars.githubusercontent.com/u/736516?v=4)](https://github.com/onnomarsman "onnomarsman (20 commits)")[![glenara](https://avatars.githubusercontent.com/u/676008?v=4)](https://github.com/glenara "glenara (8 commits)")[![Reggino](https://avatars.githubusercontent.com/u/174358?v=4)](https://github.com/Reggino "Reggino (8 commits)")[![JamieSlome](https://avatars.githubusercontent.com/u/55323451?v=4)](https://github.com/JamieSlome "JamieSlome (5 commits)")[![duzun](https://avatars.githubusercontent.com/u/321424?v=4)](https://github.com/duzun "duzun (5 commits)")[![oskarlh](https://avatars.githubusercontent.com/u/11921030?v=4)](https://github.com/oskarlh "oskarlh (5 commits)")[![simivar](https://avatars.githubusercontent.com/u/828020?v=4)](https://github.com/simivar "simivar (5 commits)")[![yadimon](https://avatars.githubusercontent.com/u/4369489?v=4)](https://github.com/yadimon "yadimon (4 commits)")[![infusion](https://avatars.githubusercontent.com/u/197742?v=4)](https://github.com/infusion "infusion (4 commits)")[![JosephThies](https://avatars.githubusercontent.com/u/24613174?v=4)](https://github.com/JosephThies "JosephThies (4 commits)")[![codemasher](https://avatars.githubusercontent.com/u/592497?v=4)](https://github.com/codemasher "codemasher (4 commits)")[![louisstow](https://avatars.githubusercontent.com/u/164316?v=4)](https://github.com/louisstow "louisstow (4 commits)")[![marcuswestin](https://avatars.githubusercontent.com/u/131967?v=4)](https://github.com/marcuswestin "marcuswestin (4 commits)")[![plepe](https://avatars.githubusercontent.com/u/249012?v=4)](https://github.com/plepe "plepe (4 commits)")[![tholum](https://avatars.githubusercontent.com/u/2395584?v=4)](https://github.com/tholum "tholum (3 commits)")

---

Tags

javascriptportsprogramming-languagestdlibtypescriptpolyfillphpjavascriptJSpythongolangstandard libraryrubyclocutus

### Embed Badge

![Health badge](/badges/locutusjs-locutus/health.svg)

```
[![Health](https://phpackages.com/badges/locutusjs-locutus/health.svg)](https://phpackages.com/packages/locutusjs-locutus)
```

###  Alternatives

[php-ds/php-ds

Specialized data structures as alternatives to the PHP array

4108.8M134](/packages/php-ds-php-ds)[yazvonov/laravel-tojs

Transform PHP Vars to JavaScript for Laravel

102.2k](/packages/yazvonov-laravel-tojs)

PHPackages © 2026

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