User Rating 0.0 β˜…β˜…β˜…β˜…β˜…
Total Usage 0 times
Enter one value per line for batch analysis
Is this tool helpful?

Your feedback helps us improve.

β˜… β˜… β˜… β˜… β˜…

About

Implicit type coercion in JavaScript is the leading cause of silent data corruption in production pipelines. A value like v = "123" passes most truthy checks but fails strict integer comparisons. This tool applies five canonical type predicates - isString, isInteger, isNumber, isBoolean, and isNotEmpty - against any raw input to produce a convertibility matrix. Results follow the same logic as the lib-control-type-for-convert specification: whitespace-only strings return TRUE for isString but FALSE for isNotEmpty. Comma-decimal numbers like "123,43" are not recognized as numeric. This tool does not use eval(). All parsing is done through safe regex and native Number/JSON.parse calls. Limitation: function detection relies on string pattern matching since actual function objects cannot be transmitted via a text input.

type checking type conversion javascript data validation type coercion value analysis developer tool

Formulas

Each predicate function applies a specific detection algorithm to the input value v. The tool first determines the interpretation of the raw input - whether it represents a JS literal or a quoted string - then runs all five checks.

isString(v) = typeof v ≑ "string"
isInteger(v) = typeof v ∈ {"string", "number"} ∧ Number(v) ∈ Z ∧ isFinite(v)
isNumber(v) = typeof v ∈ {"string", "number"} ∧ ¬isNaN(Number(v)) ∧ isFinite(Number(v))
isBoolean(v) = typeof v ≑ "boolean" ∨ String(v).toLowerCase() ∈ {"true", "false"}
isNotEmpty(v) = v β‰  NULL ∧ v β‰  undefined ∧ v β‰  NaN ∧ String(v).trim().length > 0

Where v is the input value, Z is the set of integers, Number() is the native JS coercion function, and isFinite() excludes Infinity and βˆ’Infinity. The comma-decimal format ("123,43") is intentionally rejected by isNumber because Number("123,43") returns NaN in JavaScript. For empty arrays [], isNotEmpty returns FALSE because the array has zero elements despite being a valid object.

Reference Data

Example ValueisString()isInteger()isNumber()isBoolean()isNotEmpty()
" "TRUE
''TRUE
"test"TRUETRUE
"123"TRUETRUETRUETRUE
123TRUETRUETRUE
"123.43"TRUETRUETRUE
123.43TRUETRUE
"123,43"TRUETRUE
"true"TRUETRUETRUE
TRUE (literal)TRUETRUE
"false"TRUETRUETRUE
FALSE (literal)TRUETRUE
NULL
undefined
NaN
"{}"TRUETRUE
{} (object)TRUE
"[]"TRUETRUE
[] (array)
"function(){}"TRUETRUE
function(){}TRUE
"0"TRUETRUETRUETRUE
0TRUETRUETRUE
"-5.7"TRUETRUETRUE
βˆ’5.7TRUETRUE
"Infinity"TRUETRUE
"1e5"TRUETRUETRUETRUE
"0xFF"TRUETRUETRUETRUE
"3.14.15"TRUETRUE

Frequently Asked Questions

JavaScript's native Number() constructor only recognizes the period (.) as a decimal separator. The comma in "123,43" causes Number('123,43') to return NaN. This is by design per the ECMAScript specification (Section 7.1.4.1). If you work with European-format numbers, you must replace commas with periods before type checking.
This follows the lib-control-type-for-convert convention. An empty array [] has .length === 0, meaning it contains no iterable data. An empty object {} is still a valid container with prototype methods and is considered structurally non-empty. The distinction matters in data pipelines where you iterate over arrays but access object keys.
Both pass isNumber() because Number('1e5') returns 100000 and Number('0xFF') returns 255. They also pass isInteger() since the resulting numbers are whole integers. This matches JavaScript's built-in parsing behavior. However, "0b1010" (binary) and "0o17" (octal) are also valid and will be detected correctly.
No. While Number('Infinity') returns the Infinity primitive, the isNumber() predicate explicitly requires isFinite() to return true. Infinity is not a finite number and is excluded. This prevents downstream arithmetic errors where Infinity propagates through calculations and corrupts results silently.
In String mode, your input is always treated as a quoted string (type 'string'). Typing 123 is equivalent to "123". In Literal mode, the tool attempts to parse your input as a JavaScript literal first: 123 becomes a number, true becomes a boolean, null becomes null, {} becomes an object. This distinction determines whether isString() returns TRUE or FALSE for numeric inputs.
A whitespace-only value is technically a valid string (typeof returns 'string'). However, it contains no meaningful content after trimming. The isNotEmpty() predicate calls .trim() before checking length, so " ".trim().length === 0 evaluates to empty. This catches a common bug where form inputs appear filled but contain only spaces.
Yes. The tool includes a bonus isJSON() check that attempts JSON.parse() inside a try-catch block. Strings like "{"key": "value"}" and "[1,2,3]" will pass. Plain strings like "hello" and malformed JSON like "{key: value}" will fail. Note that JSON.parse('123') and JSON.parse('true') also succeed, so valid JSON is a superset of valid numbers and booleans.