whatisgithub

What is locutus?

locutusjs/locutus — explained in plain English

Analysis updated 2026-06-26

3,771TypeScriptAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

A TypeScript library with about 500 functions ported from PHP, Python, Go, Ruby, and C into JavaScript. Use familiar functions from those languages directly in your JavaScript or TypeScript code without changing how you work with standard JS types.

Mindmap

mindmap
  root((Locutus))
    What it does
      Ports 500 functions
      Cross-language patterns
      Tree-shakeable imports
    Source languages
      PHP Python
      Go Ruby C
    How to use
      npm install
      Import by path
      Small bundle size
    Audience
      JavaScript developers
      Polyglot programmers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Use a familiar PHP string or array function directly in JavaScript by importing just that one function from Locutus.

USE CASE 2

Port a PHP or Python script to JavaScript faster by relying on Locutus equivalents for standard library functions you already know.

USE CASE 3

Import a single Go-style date-formatting function into a TypeScript project without pulling in the entire library.

USE CASE 4

Learn how standard library functions from PHP, Python, Go, or Ruby work by reading the JavaScript port implementations.

What is it built with?

TypeScriptJavaScriptnpm

How does it compare?

locutusjs/locutusthi-ng/umbrellaarikchakma/maily.to
Stars3,7713,7713,772
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderatemoderate
Complexity2/53/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Import functions by direct file path rather than by category index to keep your bundle size small.

MIT licensed, use freely in any project including commercial work, bcmath functions carry LGPL-2.1 due to their PHP origin.

So what is it?

Locutus is a TypeScript library that reimplements standard library functions from other programming languages. It brings about 500 functions from PHP, Python, Go, Ruby, and C into the JavaScript and TypeScript world, so you can call familiar patterns from those languages directly in your JavaScript or TypeScript code. Each function is separately importable, meaning your build tool can strip out the ones you do not use. The project's design philosophy is to port the behavior of each function without bringing along the underlying data structures that belong to the original language. For example, a port of a Go date-formatting function accepts a standard JavaScript Date object rather than a Go-specific time object. The idea is to get the same results as the source language while keeping the API natural for JavaScript users. The one exception is PHP, which has optional support for treating plain JavaScript objects as associative arrays to match PHP behavior more closely. You install it through npm with a single command. The recommended way to import functions is by path to the specific function you want, rather than importing an entire category index. This keeps bundle sizes small for browser applications where every extra kilobyte matters. The project started as a collection of programming puzzles and learning exercises. The maintainers note that some of these functions have genuine practical uses while others are simply interesting to write. Cross-language verification tests run against PHP 8.3 and Python 3.12 to confirm that the ports produce the same results as the originals. The library is MIT licensed, with a small exception for the PHP bcmath-related code, which carries an LGPL-2.1 license due to its origin in the PHP bcmath library.

Copy-paste prompts

Prompt 1
I know PHP and want to use array_chunk and array_combine in my JavaScript project. How do I install Locutus and import just those two functions?
Prompt 2
Show me how to use the Locutus PHP strtotime port in TypeScript to parse a human-readable date string into a JavaScript timestamp.
Prompt 3
I am porting a PHP script to JavaScript. It uses sprintf and str_pad, how do I use the Locutus versions of those in a browser bundle without importing the entire library?
Prompt 4
How does Locutus handle the difference between PHP associative arrays and JavaScript objects when porting PHP functions?
Prompt 5
Which Python functions are available in Locutus and how do I import the Python math.floor and string zfill equivalents in TypeScript?

Frequently asked questions

What is locutus?

A TypeScript library with about 500 functions ported from PHP, Python, Go, Ruby, and C into JavaScript. Use familiar functions from those languages directly in your JavaScript or TypeScript code without changing how you work with standard JS types.

What language is locutus written in?

Mainly TypeScript. The stack also includes TypeScript, JavaScript, npm.

What license does locutus use?

MIT licensed, use freely in any project including commercial work, bcmath functions carry LGPL-2.1 due to their PHP origin.

How hard is locutus to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is locutus for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.