
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
predict-data-types
Advanced tools
A lightweight, zero-dependency npm package that predicts data types for comma-separated values, including JSON objects, and validates URLs, phone numbers, email addresses, IP addresses, colors, percentages, and currency within string values.
A lightweight, zero-dependency npm package that automatically predicts data types for comma-separated values. Supports 14 data types including primitives, URLs, emails, UUIDs, dates, IP addresses, colors, percentages, and currency.
npm install predict-data-types
| Type | Examples |
|---|---|
string | 'John', 'Hello World' |
number | 42, 3.14, -17, 1e10 |
boolean | true, false, yes, no |
email | user@example.com |
phone | 555-555-5555, (555) 555-5555 |
url | https://example.com |
uuid | 550e8400-e29b-41d4-a716-446655440000 |
date | 2023-12-31, 31/12/2023 |
ip | 192.168.1.1, 2001:0db8::1 |
color | #FF0000, #fff |
percentage | 50%, -25% |
currency | $100, €50.99 |
array | [1, 2, 3] |
object | {"name": "John"} |
const predictDataTypes = require("predict-data-types");
const text = "John, 30, true, john@example.com, 2023-01-01";
const types = predictDataTypes(text);
console.log(types);
// {
// 'John': 'string',
// '30': 'number',
// 'true': 'boolean',
// 'john@example.com': 'email',
// '2023-01-01': 'date'
// }
const csvData = `name,age,active,email
John,30,true,john@example.com`;
const types = predictDataTypes(csvData, true);
// {
// 'name': 'string',
// 'age': 'number',
// 'active': 'boolean',
// 'email': 'email'
// }
const data = "192.168.1.1, #FF0000, 50%, $100, 2023-12-31";
const types = predictDataTypes(data);
// {
// '192.168.1.1': 'ip',
// '#FF0000': 'color',
// '50%': 'percentage',
// '$100': 'currency',
// '2023-12-31': 'date'
// }
predictDataTypes(input, firstRowIsHeader)Parameters:
input (string): Comma-separated string to analyzefirstRowIsHeader (boolean): Treat first row as headers (default: false)Returns: Object mapping field names/values to their data types
Throws: Error if input is null, undefined, or not a string
npm test # Run tests
npm run test:coverage # Run tests with coverage
npm run lint # Check code quality
npm run lint:fix # Fix lint issues
MIT License - see LICENSE file for details.
See CONTRIBUTING.md for contribution guidelines.
Author: Melih Birim
FAQs
A lightweight, zero-dependency npm package that predicts data types for comma-separated values, including JSON objects, and validates URLs, phone numbers, email addresses, IP addresses, colors, percentages, and currency within string values.
The npm package predict-data-types receives a total of 20 weekly downloads. As such, predict-data-types popularity was classified as not popular.
We found that predict-data-types demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.