PHPackages                             mpyw/uuid-ulid-converter - 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. mpyw/uuid-ulid-converter

ActiveLibrary

mpyw/uuid-ulid-converter
========================

UUID &lt;=&gt; ULID bidirectional converter

v1.1.0(1y ago)8183.2k↓25.8%MITPHPPHP &gt;=8.2CI passing

Since Oct 27Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/mpyw/uuid-ulid-converter)[ Packagist](https://packagist.org/packages/mpyw/uuid-ulid-converter)[ RSS](/packages/mpyw-uuid-ulid-converter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

uuid-ulid-converter
===================

[](#uuid-ulid-converter)

[![Build Status](https://github.com/mpyw/uuid-ulid-converter/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mpyw/uuid-ulid-converter/actions) [![Coverage Status](https://camo.githubusercontent.com/1068ee9f1fcbfe0ea1db97b830dc3c0633a14bfbd0ec761fcc47de2f6ae53af3/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d7079772f757569642d756c69642d636f6e7665727465722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/mpyw/uuid-ulid-converter?branch=master)

[UUID](https://datatracker.ietf.org/doc/html/rfc4122) &lt;=&gt; [ULID](https://github.com/ulid/spec) bidirectional converter

Installing
----------

[](#installing)

```
composer require mpyw/uuid-ulid-converter

```

Requirements
------------

[](#requirements)

PackageVersionPHP`^8.2`Note

Older versions have outdated dependency requirements. If you cannot prepare the latest environment, please refer to past releases.

API
---

[](#api)

```
public static Converter::uuidToUlid(string $uuid, bool $lowercase = false): string
public static Converter::ulidToUuid(string $ulid, bool $uppercase = false): string
```

Important

**UUID is lowercase by default, whereas ULID is uppercase by default.**

Usage
-----

[](#usage)

### Basic

[](#basic)

```
use Mpyw\UuidUlidConverter\Converter;

var_dump(Converter::ulidToUuid('61862H2EWP9TCTRX3MJ15XNY7X'));
// string(36) "c1418511-3b96-4e99-ac74-74904bdaf8fd"

var_dump(Converter::uuidToUlid('c1418511-3b96-4e99-ac74-74904bdaf8fd'));
// string(26) "61862H2EWP9TCTRX3MJ15XNY7X"
```

### Advanced

[](#advanced)

The following workarounds are particularly useful in the PostgreSQL, which does not support ULID but does support UUID. Storing ULID as native UUID is more efficient than storing original ULID as strings.

Introduce advanced usages with [robinvdvleuten/php-ulid](https://github.com/robinvdvleuten/php-ulid).

#### Generate UUID-styled ULID

[](#generate-uuid-styled-ulid)

```
use Mpyw\UuidUlidConverter\Converter;
use Ulid\Ulid;

// Use generated UUID as primary key
$uuid = Converter::ulidToUuid((string)Ulid::generate());
```

#### Timestamp range of UUID-styled ULID

[](#timestamp-range-of-uuid-styled-ulid)

```
use Mpyw\UuidUlidConverter\Converter;
use Ulid\Ulid;

$dates = [
    new \DateTimeImmutable('2020-01-01 00:00:00.000 UTC'),
    new \DateTimeImmutable('2020-01-02 00:00:00.000 UTC'),
];

function createUuidRange(array $dates): array
{
    $createPart = fn (\DateTimeInterface $date, bool $isEnd) => Converter::ulidToUuid(
        Ulid::fromTimestamp(round((int)$date->format('Uu') / 1000))->getTime()
        . str_repeat($isEnd ? 'Z' : '0', 16),
    );
    return [
        $createPart($dates[0], false),
        $createPart($dates[1], true),
    ];
}

$uuids = createUuidRange($dates);
/*
array(2) {
  [0]=>
  string(36) "016f5e66-e800-0000-0000-000000000000"
  [1]=>
  string(36) "016f638d-4400-ffff-ffff-ffffffffffff"
}
*/
```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance60

Regular maintenance activity

Popularity37

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~1224 days

Total

2

Last Release

440d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.4

v1.1.0PHP &gt;=8.2

### Community

Maintainers

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

---

Top Contributors

[![mpyw](https://avatars.githubusercontent.com/u/1351893?v=4)](https://github.com/mpyw "mpyw (19 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mpyw-uuid-ulid-converter/health.svg)

```
[![Health](https://phpackages.com/badges/mpyw-uuid-ulid-converter/health.svg)](https://phpackages.com/packages/mpyw-uuid-ulid-converter)
```

PHPackages © 2026

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