
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
<!-- HTML5 -->
<script type="module">
import { UUID } from "https://unpkg.com/uuidjs@^5";
const uuid = UUID.generate();
</script>
// Node.js
import { UUID } from "uuidjs";
const uuid = UUID.generate();
// TypeScript
import { UUID } from "uuidjs";
const str: string = UUID.generate();
const obj: UUID = UUID.genV4();
# Command-line
npx uuidjs
UUID.js is a JavaScript/ECMAScript library to generate RFC 9562 compliant Universally Unique IDentifiers (UUIDs). This library supports UUIDv4 (random number-based UUIDs), UUIDv1 (Gregorian time-based UUIDs), and UUIDv6 (Reordered Gregorian time-based UUIDs). It also provides an object-oriented interface to print a generated or parsed UUID in a variety of forms.
Math.random()
otherwiseImport UUID
class:
import { UUID } from "uuidjs";
// or on browsers:
// import { UUID } from "https://unpkg.com/uuidjs@^5";
UUID.generate()
returns a UUIDv4 as a hexadecimal string.
// Create a UUIDv4 as a hexadecimal string
console.log(UUID.generate()); // fa84cf42-ffdf-4975-b42b-31ab5fb983eb
UUID.genV4()
, UUID.genV1()
, UUID.genV6()
, and UUID.parse()
return a UUID
object that has various fields and methods.
// Create a UUIDv4 (random number-based UUID) object
const objV4 = UUID.genV4();
// Create a UUIDv1 (Gregorian time-based UUID) object
const objV1 = UUID.genV1();
// Create a UUIDv6 (Reordered Gregorian time-based UUID) object
const objV6 = UUID.genV6();
// Create a UUID object from a hexadecimal string
const uuid = UUID.parse("a0e0f130-8c21-11df-92d9-95795a3bcd40");
// Get string representations of a UUID object
console.log(uuid.toString()); // "a0e0f130-8c21-11df-92d9-95795a3bcd40"
console.log(uuid.hexString); // "a0e0f130-8c21-11df-92d9-95795a3bcd40"
console.log(uuid.hexNoDelim); // "a0e0f1308c2111df92d995795a3bcd40"
console.log(uuid.bitString); // "101000001110000 ... 1100110101000000"
console.log(uuid.urn); // "urn:uuid:a0e0f130-8c21-11df-92d9-95795a3bcd40"
// Compare UUID objects
console.log(objV4.equals(objV1)); // false
// Get UUID version numbers
console.log(objV4.version); // 4
console.log(objV1.version); // 1
console.log(objV6.version); // 6
Copyright (c) 2010-2024 LiosK
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
LiosK contact@mail.liosk.net
v5.1.0 - 2024-05-12
UUID.genV6()
as stableFAQs
RFC-compliant UUID Generator for JavaScript
We found that uuidjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.