BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/utilcn/to-pascal-case

To Pascal Case

utilcn/to-pascal-case
FreeUtility

Convert a string to PascalCase.

Install it

npx shadcn@latest add https://utilcn.dev/r/to-pascal-case.json

Source

registry/default/strings/to-pascal-case.tsutilcn.dev/r/to-pascal-case.json
1/**
2 * Converts a string to PascalCase.
3 *
4 * Handles acronyms properly, ensuring that something like
5 * "XMLHttpRequest" becomes "XmlHttpRequest".
6 *
7 * @param str - The input string.
8 * @returns The PascalCased string.
9 *
10 * @example
11 * toPascalCase("hello world-example"); // "HelloWorldExample"
12 * toPascalCase("XMLHttpRequest"); // "XmlHttpRequest"
13 */
14export function toPascalCase(str: string): string {
15 return (
16 str
17 // Split acronym groups into proper boundaries
18 .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
19 // Split between lowercase/digit and uppercase
20 .replace(/([a-z\d])([A-Z])/g, '$1 $2')
21 // Normalize spaces/underscores/dashes
22 .replace(/[-_\s]+/g, ' ')
23 // Lowercase all to normalize
24 .toLowerCase()
25 // Capitalize every word
26 .replace(/\b\w/g, (c) => c.toUpperCase())
27 // Remove spaces
28 .replace(/\s+/g, '')
29 );
30}

Files it writes

  • registry/default/strings/to-pascal-case.ts

Facts

Registry
utilcn
Type
registry:lib
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-04
Last confirmed
today

Go to the source

utilcn.dev BrennenRocks/utilcn on GitHub Raw registry item This item as JSON

More from utilcn

All 17 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
CapitalizecapitalizeutilcnUtilitiesFreeno deps
Capitalize Allcapitalize-allutilcnUtilitiesFreeno deps
Environment Server Configurationenv-serverutilcnUtilitiesFree1 dep
Generate Presigned Download URLgenerate-presigned-download-urlutilcnUtilitiesFree2 deps · 2 files
Generate Presigned Upload URLgenerate-presigned-upload-urlutilcnUtilitiesFree2 deps · 2 files
Repeat Padrepeat-padutilcnUtilitiesFreeno deps
Reverse Stringreverse-stringutilcnUtilitiesFreeno deps
To Camel Caseto-camel-caseutilcnUtilitiesFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex