# extract-stringtag

> Extracts the internal class name (Tag) from a string formatted as '[object Tag]'.

Latest version **1.0.1** (published 2025-12-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install extract-stringtag
pnpm add extract-stringtag
yarn add extract-stringtag
bun add extract-stringtag
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2025-12-23 |
| First published | 2025-12-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | tj-commits |
| Maintainers | tj-commits, xsfj |
| Keywords | stringtag |

## Links

- npm: https://www.npmjs.com/package/extract-stringtag
- Repository: https://github.com/tj-commits/extract-stringtag
- Homepage: https://github.com/tj-commits/extract-stringtag#readme
- Issues: https://github.com/tj-commits/extract-stringtag/issues
- npm.io page: https://npm.io/package/extract-stringtag

## Dependencies (2)

- [uncurried-intrinsics](https://npm.io/package/uncurried-intrinsics.md) ^1.0.1
- [@is-(unknown)/is-string](https://npm.io/package/@is-(unknown)/is-string.md) ^1.0.0

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2025-12-23
- 1.0.0 — 2025-12-17

## README

# extract-stringtag

A lightweight utility to extract the internal class name (like `Function`) from a string formatted like `[object Function]`. This is particularly useful when working with custom objects that implement `Symbol.toStringTag` or for parsing results from `Object.prototype.toString`.

---

## Installation

```bash
npm install extract-stringtag
```

## Usage

This module identifies if a string follows the standard `[object Tag]` pattern and returns only the `Tag` portion. If the input is not a string or doesn't match the pattern, it returns null.

```javascript

const extractStringTag = require('extract-stringtag');

// Standard built-in tags
extractStringTag('[object Array]')     // 'Array'
extractStringTag('[object Object]')    // 'Object'
extractStringTag('[object Promise]')   // 'Promise'

// Custom tags
extractStringTag('[object MyClass]')   // 'MyClass'

// Invalid inputs
extractStringTag('not a tag')          // null
extractStringTag(123)                  // null
extractStringTag('[object Unclosed')   // null
```

## License
Unlicense

## Tests
do a git clone, then run `npm test`

---
_Source: https://npm.io/package/extract-stringtag · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
