npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

uuid-kit

v2.0.2

Published

Generate UUID values (v4, v7) with formatting, prefixes, suffixes, and flexible output shapes.

Readme

uuid-kit

Generate UUID values (v4, v7) with flexible formatting, prefixes, suffixes, and output shape options.

Previously published as generate-uuid-version


Install

npm install uuid-kit

Usage

import { generateUUID } from "uuid-kit";

const result = generateUUID({
  count: 3,
  version: "v7"
});

console.log(result);

Output

{
  "version": "v7",
  "format": "standard",
  "output_as": "array",
  "count": 3,
  "items": [
    "uuid-1",
    "uuid-2",
    "uuid-3"
  ]
}

Options

| Field | Type | Required | Default | Description | |------|------|----------|---------|-------------| | count | number | No | 1 | Number of UUIDs to generate | | version | string | No | v7 | UUID version: v4 or v7 | | format | string | No | standard | Output format: standard, compact, uppercase, uppercase-compact | | prefix | string | No | "" | String to prepend to each UUID | | suffix | string | No | "" | String to append to each UUID | | outputAs | string | No | array | Output shape: array, object, or string |


Examples

Default

generateUUID({ count: 2 });

Output:

{
  "version": "v7",
  "format": "standard",
  "output_as": "array",
  "count": 2,
  "items": [
    "uuid-1",
    "uuid-2"
  ]
}

v4

generateUUID({
  count: 2,
  version: "v4"
});

v7

generateUUID({
  count: 2,
  version: "v7"
});

Compact format

generateUUID({
  count: 2,
  format: "compact"
});

Uppercase + prefix

generateUUID({
  count: 2,
  format: "uppercase",
  prefix: "id_"
});

Prefix + suffix

generateUUID({
  count: 2,
  prefix: "pre_",
  suffix: "_end"
});

Object output

generateUUID({
  count: 2,
  outputAs: "object"
});

Output:

{
  "version": "v7",
  "format": "standard",
  "output_as": "object",
  "count": 2,
  "items": [
    {
      "uuid": "uuid-1",
      "raw": "uuid-1",
      "index": 0,
      "timestamp": {
        "iso": "2026-04-09T18:12:34.567Z",
        "unix": 1775758354567
      }
    },
    {
      "uuid": "uuid-2",
      "raw": "uuid-2",
      "index": 1,
      "timestamp": {
        "iso": "2026-04-09T18:12:35.123Z",
        "unix": 1775758355123
      }
    }
  ]
}

String output

generateUUID({
  count: 3,
  outputAs: "string"
});

Output:

{
  "version": "v7",
  "format": "standard",
  "output_as": "string",
  "count": 3,
  "items": "uuid-1\nuuid-2\nuuid-3"
}

Formats

  • standard = default UUID format
  • compact = removes hyphens
  • uppercase = uppercase letters
  • uppercase-compact = uppercase and no hyphens

Output Shapes

outputAs: "array"

Returns items as an array of formatted UUID strings.

outputAs: "object"

Returns items as an array of objects.

Each object includes:

  • uuid = final formatted value
  • raw = original UUID before formatting
  • index = zero-based position in the result set
  • timestamp = only included for v7 when outputAs is "object"

outputAs: "string"

Returns items as a single newline-delimited string.


Supported Versions

  • v4 = random
  • v7 = time-based, sortable, recommended

Exposed Constants

import {
  ALLOWED_FORMATS,
  ALLOWED_VERSIONS,
  ALLOWED_OUTPUT_AS
} from "uuid-kit";

Behavior

  • Invalid or missing count defaults to 1
  • Maximum count is 100
  • count is floored to a whole number
  • Invalid or missing version defaults to v7
  • Invalid or missing format defaults to standard
  • Invalid or missing outputAs defaults to array

Performance Notes

uuid-kit avoids unnecessary work during generation:

  • Object records are only built when outputAs is "object"
  • Timestamps are only extracted for v7 object output
  • Array storage is preallocated for efficient generation

This keeps array and string output paths lighter and faster.


TypeScript

The package includes TypeScript definitions for:

  • UUIDVersion
  • UUIDFormat
  • UUIDOutputAs
  • UUIDTimestamp
  • UUIDObject
  • GenerateUUIDOptions
  • GenerateUUIDResult

The generateUUID() function also uses overloads so the return type matches outputAs when it is explicitly provided.


Environment Notes

Some hosted JavaScript runtimes require you to explicitly add npm packages before use. In those environments, add:

  • uuid-kit
  • uuid@10

License

MIT