{"id":51039291,"url":"https://github.com/sharjeelfaiq/superbstring","last_synced_at":"2026-06-22T09:30:29.661Z","repository":{"id":241957243,"uuid":"808348172","full_name":"sharjeelfaiq/superbstring","owner":"sharjeelfaiq","description":"Zero-dependency JavaScript/TypeScript string utilities for text cleanup, slugify, Base64, formatting, and transforms.","archived":false,"fork":false,"pushed_at":"2026-06-01T02:56:00.000Z","size":4968,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-01T03:12:05.363Z","etag":null,"topics":["base64","javascript","npm-package","slugify","string-utils","text-cleanup","text-processing","typescript","utility-library","zero-dependency"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/superbstring","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sharjeelfaiq.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-30T22:09:35.000Z","updated_at":"2026-06-01T02:56:03.000Z","dependencies_parsed_at":"2024-05-30T22:44:27.993Z","dependency_job_id":"d5b51956-cb0c-467a-b188-f58c29a6c449","html_url":"https://github.com/sharjeelfaiq/superbstring","commit_stats":null,"previous_names":["sharjeelfaiq/superbstring","sharjeelfaiq/superbstring-npm-library"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/sharjeelfaiq/superbstring","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharjeelfaiq%2Fsuperbstring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharjeelfaiq%2Fsuperbstring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharjeelfaiq%2Fsuperbstring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharjeelfaiq%2Fsuperbstring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sharjeelfaiq","download_url":"https://codeload.github.com/sharjeelfaiq/superbstring/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharjeelfaiq%2Fsuperbstring/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34643410,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base64","javascript","npm-package","slugify","string-utils","text-cleanup","text-processing","typescript","utility-library","zero-dependency"],"created_at":"2026-06-22T09:30:28.964Z","updated_at":"2026-06-22T09:30:29.652Z","avatar_url":"https://github.com/sharjeelfaiq.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SuperbString\n\nZero-dependency JavaScript and TypeScript string utilities for cleanup, case conversion, extraction, encoding, and AI/RAG text preparation.\n\n[![npm version](https://img.shields.io/npm/v/superbstring.svg)](https://www.npmjs.com/package/superbstring)\n[![npm weekly downloads](https://img.shields.io/npm/dw/superbstring.svg)](https://www.npmjs.com/package/superbstring)\n[![license: ISC](https://img.shields.io/npm/l/superbstring.svg)](LICENSE)\n[![TypeScript support](https://img.shields.io/badge/TypeScript-supported-blue.svg)](dist/index.d.ts)\n[![Zero Dependencies](https://img.shields.io/badge/dependencies-zero-brightgreen.svg)](package.json)\n[![CI](https://github.com/sharjeelfaiq/superbstring/actions/workflows/ci.yml/badge.svg)](https://github.com/sharjeelfaiq/superbstring/actions/workflows/ci.yml)\n\n---\n\n## Why SuperbString?\n\n- Zero runtime dependencies\n- TypeScript support with bundled declarations\n- CommonJS-friendly package output\n- AI, LLM, and RAG text-processing helpers\n- Case conversion utilities, including `case-string` migration APIs\n- Text cleanup, extraction, counting, encoding, and formatting helpers\n- Small, focused package contents\n- Maintained with tests, CI, changelog, security policy, and contribution docs\n\n## Installation\n\n```bash\nnpm install superbstring\n```\n\n## Quick Start\n\n```javascript\nconst {\n  slugify,\n  camelCase,\n  extractEmails,\n  chunkText,\n  removeMarkdown,\n  stripHtml,\n  safeJsonParse,\n  wordCount,\n  sentenceCount,\n} = require(\"superbstring\");\n\nslugify(\"Hello, World!\"); // \"hello-world\"\ncamelCase(\"user profile-title\"); // \"userProfileTitle\"\nextractEmails(\"Email a+b@example.co.uk\"); // [\"a+b@example.co.uk\"]\nchunkText(\"one two three four five\", 10); // [\"one two\", \"three four\", \"five\"]\nremoveMarkdown(\"## Hi\\n**bold** [site](https://example.com)\"); // \"Hi\\nbold site\"\nstripHtml(\"\u003cp\u003eHello \u003cstrong\u003eworld\u003c/strong\u003e\u003c/p\u003e\"); // \"Hello world\"\nsafeJsonParse('{\"ok\":true}'); // { ok: true }\nsafeJsonParse(\"{bad\", {}); // {}\nwordCount(\"Hello, world! 123\"); // 3\nsentenceCount(\"One. Two! Three?\"); // 3\n```\n\nTypeScript named imports work out of the box:\n\n```typescript\nimport { slugify, chunkText, type CodeBlock } from \"superbstring\";\n\nconst slug: string = slugify(\"Hello, World!\");\nconst chunks: string[] = chunkText(\"context for retrieval\", 500);\nconst block: CodeBlock = { language: \"ts\", code: \"const ok = true;\" };\n```\n\n## Common Use Cases\n\n### AI \u0026 LLM Text Processing\n\nClean model output, prepare context for retrieval, and parse generated JSON safely.\n\n```javascript\nconst {\n  stripHtml,\n  removeMarkdown,\n  extractCodeBlocks,\n  removeCodeBlocks,\n  chunkText,\n  safeJsonParse,\n} = require(\"superbstring\");\n\nconst source = \"\u003carticle\u003e## Intro\\nUseful **context**.\u003c/article\u003e\";\nconst plainText = removeMarkdown(stripHtml(source)); // \"Intro\\nUseful context.\"\nconst chunks = chunkText(plainText, 500); // [\"Intro\\nUseful context.\"]\n\nconst blocks = extractCodeBlocks(\"```js\\nconsole.log(1);\\n```\");\n// [{ language: \"js\", code: \"console.log(1);\" }]\n\nremoveCodeBlocks(\"before\\n```js\\nconsole.log(1);\\n```\\nafter\");\n// \"before\\nafter\"\n\nsafeJsonParse('{\"answer\":\"yes\"}', {}); // { answer: \"yes\" }\nsafeJsonParse(\"not json\", {}); // {}\n```\n\n### Case Conversion\n\nConvert user input, headings, labels, filenames, and keys into predictable case formats.\n\n```javascript\nconst {\n  camelCase,\n  pascalCase,\n  snakeCase,\n  kebabCase,\n  constantCase,\n  trainCase,\n  dotCase,\n  pathCase,\n} = require(\"superbstring\");\n\ncamelCase(\"user profile-title\"); // \"userProfileTitle\"\npascalCase(\"user profile-title\"); // \"UserProfileTitle\"\nsnakeCase(\"User Profile-Title\"); // \"user_profile_title\"\nkebabCase(\"User_Profile Title\"); // \"user-profile-title\"\nconstantCase(\"user profile-title\"); // \"USER_PROFILE_TITLE\"\ntrainCase(\"user profile-title\"); // \"User-Profile-Title\"\ndotCase(\"User profile-title\"); // \"user.profile.title\"\npathCase(\"User profile-title\"); // \"user/profile/title\"\n```\n\n### Text Cleanup\n\nNormalize messy user-generated text before saving, searching, indexing, or sending it to another system.\n\n```javascript\nconst {\n  normalizeWhitespace,\n  normalizeLineEndings,\n  removeDuplicateLines,\n  stripHtml,\n  removeAllSymbols,\n  normalizeUnicode,\n} = require(\"superbstring\");\n\nnormalizeWhitespace(\"  a   b\\tc\\n \"); // \"a b c\"\nnormalizeLineEndings(\"a\\r\\nb\\rc\"); // \"a\\nb\\nc\"\nremoveDuplicateLines(\"alpha\\nbeta\\nalpha\"); // \"alpha\\nbeta\"\nstripHtml(\"\u003cp\u003eHello \u003cstrong\u003eworld\u003c/strong\u003e\u003c/p\u003e\"); // \"Hello world\"\nremoveAllSymbols(\"Hello, World!\"); // \"Hello World\"\nnormalizeUnicode(\"e\\u0301\"); // \"\\u00e9\"\n```\n\n### Extraction Utilities\n\nPull useful structured data out of text without adding a parsing dependency.\n\n```javascript\nconst { extractUrls, extractEmails, extractText, extractNumber } = require(\"superbstring\");\n\nextractUrls(\"Visit https://example.com.\"); // [\"https://example.com\"]\nextractEmails(\"Email a+b@example.co.uk\"); // [\"a+b@example.co.uk\"]\nextractText(\"Order #123 ships today.\"); // \"Order  ships today\"\nextractNumber(\"Order #123 ships today.\"); // \" 123  \"\n```\n\n### Analytics Utilities\n\nCount simple text metrics for previews, validations, dashboards, and content checks.\n\n```javascript\nconst { wordCount, charCount, sentenceCount } = require(\"superbstring\");\n\nwordCount(\"Hello, world! 123\"); // 3\ncharCount(\"a🙂\"); // 2\nsentenceCount(\"One. Two! Three?\"); // 3\n```\n\n## API Reference\n\n### Text Cleanup\n\n| Function | Description |\n| --- | --- |\n| `normalizeWhitespace(str)` | Collapse repeated whitespace into single spaces and trim. |\n| `normalizeLineEndings(str, newline?)` | Convert CRLF, CR, and LF to `\"\\n\"` or `\"\\r\\n\"`. |\n| `normalizeUnicode(str, form?)` | Normalize Unicode with native `String.prototype.normalize`. |\n| `removeExtraSpaces(str)` | Collapse whitespace, trim, and remove spaces before punctuation. |\n| `removeAllSpaces(str)` | Remove all whitespace. |\n| `removeAllSymbols(str)` | Keep alphanumeric characters and spaces. |\n| `removeDuplicateLines(str)` | Remove repeated lines while keeping first occurrences. |\n| `stripHtml(str)` | Remove HTML comments and tags for text cleanup. |\n| `removeMarkdown(str)` | Remove common Markdown syntax while keeping readable text. |\n| `removeCodeBlocks(str)` | Remove triple-backtick fenced Markdown code blocks. |\n| `paraToSingleLine(str)` | Collapse whitespace into one line. |\n\n### AI, LLM, and RAG Helpers\n\n| Function | Description |\n| --- | --- |\n| `splitIntoParagraphs(str)` | Split text into trimmed, non-empty paragraphs. |\n| `chunkText(str, maxLength, overlap?)` | Split text into character-length chunks. |\n| `truncateWords(str, maxWords, suffix?)` | Limit text by word count and append a suffix only when truncated. |\n| `extractCodeBlocks(str)` | Extract fenced Markdown code blocks as `{ language, code }` objects. |\n| `removeCodeBlocks(str)` | Remove fenced Markdown code blocks from prose. |\n| `safeJsonParse(str, fallback?)` | Parse JSON without throwing; return `fallback` or `null` on failure. |\n\n### Case Conversion\n\n| Function | Description |\n| --- | --- |\n| `camelCase(str)` | Convert ASCII word-like sequences to `camelCase`. |\n| `pascalCase(str)` | Convert ASCII word-like sequences to `PascalCase`. |\n| `snakeCase(str)` | Convert ASCII word-like sequences to `snake_case`. |\n| `kebabCase(str)` | Convert ASCII word-like sequences to `kebab-case`. |\n| `titleCase(str)` | Convert ASCII word-like sequences to `Title Case`. |\n| `capitalize(str)` | Uppercase the first character and leave the rest unchanged. |\n| `lowerCase(str)` | Convert text to lowercase. |\n| `upperCase(str)` | Convert text to uppercase. |\n| `constantCase(str)` | Convert ASCII word-like sequences to `CONSTANT_CASE`. |\n| `pascalSnakeCase(str)` | Convert ASCII word-like sequences to `Pascal_Snake_Case`. |\n| `trainCase(str)` | Convert ASCII word-like sequences to `Train-Case`. |\n| `dotCase(str)` | Convert ASCII word-like sequences to `dot.case`. |\n| `pathCase(str)` | Convert ASCII word-like sequences to `path/case`. |\n| `invertCase(str)` | Invert uppercase and lowercase characters. |\n| `reverseTitleCase(str)` | Lowercase words and uppercase the final character of each word. |\n| `alternateCase1(str)` | Alternate character casing starting uppercase. |\n| `alternateCase2(str)` | Alternate character casing starting lowercase. |\n| `toggleCase(str)` | Uppercase words and lowercase each first character. |\n| `noCase(str)` | Convert common separated and camelCase input to lowercase words. |\n| `sentenceCase(str)` | Convert basic text to sentence case. |\n\n### Extraction\n\n| Function | Description |\n| --- | --- |\n| `extractUrls(str)` | Extract HTTP and HTTPS URLs. |\n| `extractEmails(str)` | Extract email-looking addresses. |\n| `extractCodeBlocks(str)` | Extract triple-backtick fenced Markdown code blocks. |\n| `extractText(str)` | Keep letters and spaces only. |\n| `extractNumber(str)` | Keep digits and spaces only. |\n\n### Counting and Analysis\n\n| Function | Description |\n| --- | --- |\n| `wordCount(str)` | Count ASCII word-like sequences. |\n| `charCount(str)` | Count Unicode code points. |\n| `sentenceCount(str)` | Count groups of `.`, `!`, and `?`. |\n| `isSlug(str)` | Validate lowercase URL slugs with single hyphen separators. |\n\n### Formatting and General String Utilities\n\n| Function | Description |\n| --- | --- |\n| `slugify(str)` | Lowercase text, replace spaces with hyphens, and remove non-word characters except hyphens. |\n| `splitString(str, delimiter?)` | Replace delimiter occurrences with newline characters. |\n| `joinString(str)` | Replace newline characters with spaces. |\n| `duplicate(str, count?)` | Repeat a string. |\n| `reverse(str)` | Reverse UTF-16 code units. |\n| `truncate(str, length)` | Return `str.substring(0, length)`. |\n| `alphabetize(str)` | Sort space-separated words with `localeCompare`. |\n| `addPrefix(str, prefix)` | Add a prefix. |\n| `addSuffix(str, suffix)` | Add a suffix. |\n| `getDummyText()` | Return Lorem ipsum placeholder text. |\n| `getRandomCharacters(length)` | Generate a random string from letters, numbers, and symbols. |\n| `zalgo(str)` | Add random combining marks to each non-space character. |\n| `rotate13Deg(str)` | Apply ROT13 to alphabetic characters. |\n\n### Encoding\n\n| Function | Description |\n| --- | --- |\n| `base64Encode(str)` | Encode a string as Base64 using platform `btoa`. |\n| `base64Decode(str)` | Decode a Base64 string using platform `atob`. |\n| `compare(str, encodedStr)` | Return whether `encodedStr` decodes to `str`; invalid Base64 returns `false`. |\n| `encodeUri(str)` | Encode a URI with JavaScript `encodeURI`. |\n| `decodeUri(str)` | Decode a URI with JavaScript `decodeURI`. |\n\n### Types\n\n| Type | Description |\n| --- | --- |\n| `CodeBlock` | Object returned by `extractCodeBlocks`: `{ language: string; code: string }`. |\n\n## Migration Guide\n\n### Migrating from `case-string`\n\n`case-string` style case-conversion APIs are available inside SuperbString, so projects can consolidate on one zero-dependency string utility package.\n\n```javascript\nconst {\n  lowerCase,\n  upperCase,\n  reverseTitleCase,\n  invertCase,\n  constantCase,\n  pascalSnakeCase,\n  trainCase,\n  dotCase,\n  pathCase,\n  alternateCase1,\n  alternateCase2,\n  toggleCase,\n  noCase,\n  sentenceCase,\n} = require(\"superbstring\");\n```\n\n| From `case-string` style usage | Use in `superbstring` |\n| --- | --- |\n| Lowercase text | `lowerCase(str)` |\n| Uppercase text | `upperCase(str)` |\n| Reverse title casing | `reverseTitleCase(str)` |\n| Invert character case | `invertCase(str)` |\n| `CONSTANT_CASE` | `constantCase(str)` |\n| `Pascal_Snake_Case` | `pascalSnakeCase(str)` |\n| `Train-Case` | `trainCase(str)` |\n| `dot.case` | `dotCase(str)` |\n| `path/case` | `pathCase(str)` |\n| Alternating case, uppercase first | `alternateCase1(str)` |\n| Alternating case, lowercase first | `alternateCase2(str)` |\n| Toggle word case | `toggleCase(str)` |\n| Lowercase words | `noCase(str)` |\n| Sentence case | `sentenceCase(str)` |\n\n## TypeScript Support\n\nSuperbString ships generated declaration files through the package `types` field. No separate `@types` package is needed.\n\n```typescript\nimport {\n  camelCase,\n  extractEmails,\n  safeJsonParse,\n  type CodeBlock,\n} from \"superbstring\";\n\nconst key: string = camelCase(\"User Profile Title\");\nconst emails: string[] = extractEmails(\"Contact hello@example.com\");\nconst value = safeJsonParse\u003c{ ok: boolean }\u003e('{\"ok\":true}', { ok: false });\nconst block: CodeBlock = { language: \"js\", code: \"console.log(1);\" };\n```\n\n## Behavior Notes\n\n- `chunkText` is character-length based, not token based.\n- `stripHtml` removes tags for text cleanup; it is not a browser security sanitizer.\n- `removeMarkdown` is lightweight cleanup, not a full Markdown parser.\n- `safeJsonParse` does not repair invalid JSON.\n- `getRandomCharacters` and `zalgo` use `Math.random()` and are not cryptographically secure.\n- `reverse` reverses UTF-16 code units, so complex Unicode characters can be split.\n- `charCount` counts Unicode code points, not grapheme clusters.\n- `sentenceCount` is a basic punctuation counter, not a natural-language sentence parser.\n- Case conversion helpers based on word splitting use ASCII word-like sequences.\n- `base64Encode`, `base64Decode`, and `compare` rely on platform `btoa` and `atob`.\n- `encodeUri` and `decodeUri` use JavaScript `encodeURI` and `decodeURI`.\n\n## FAQ\n\n### Does it have dependencies?\n\nNo. SuperbString has zero runtime dependencies.\n\n### Does it work in Node.js?\n\nYes. The package targets Node.js `\u003e=16` and publishes CommonJS output.\n\n### Does it work with TypeScript?\n\nYes. Type declarations are bundled and named imports are supported.\n\n### Can I use it for AI applications?\n\nYes. It includes dependency-free helpers for prompt cleanup, Markdown/HTML cleanup, code block extraction, text chunking, paragraph splitting, and safe JSON parsing.\n\n### Is it tree-shakeable?\n\nThe package marks `\"sideEffects\": false` and exports pure utility functions, which helps modern bundlers remove unused code.\n\n### Is it a sanitizer or parser?\n\nNo. Utilities such as `stripHtml`, `removeMarkdown`, `sentenceCount`, and `chunkText` are lightweight text helpers, not security sanitizers, full parsers, or tokenizers.\n\n## Project Information\n\n- [Changelog](CHANGELOG.md)\n- [Contributing](CONTRIBUTING.md)\n- [Security Policy](SECURITY.md)\n- [Code of Conduct](CODE_OF_CONDUCT.md)\n- [GitHub Issues](https://github.com/sharjeelfaiq/superbstring/issues)\n- [npm Package](https://www.npmjs.com/package/superbstring)\n\n## License\n\n[ISC](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharjeelfaiq%2Fsuperbstring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharjeelfaiq%2Fsuperbstring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharjeelfaiq%2Fsuperbstring/lists"}