JS expression static evaluator
It does **not** execute arbitrary JS in the browser (no eval / Function): a hand-written parser evaluates pure literal expressions — numbers, strings, booleans, null, array and object literals, the + - * / % operators (including unary minus), parentheses and string concatenation with +. Results can be shown as a preview (value + type), JSON or a JS literal. Boundary: input containing variables, function calls, assignments, template literals, =>, new or member access throws unsupported-expression, division by zero throws division-by-zero, and nothing is guessed.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Result
The result can be copied directly.
Enter a literal expression (e.g. 1 + 2 * 3) to evaluate it
Characters: 0 · Result type: 0 · Evaluated nodes: 0
What this tool does
- Quickly check the value and type of a literal expression.
- Normalise object / array literals into JSON or JS output.
- Demonstrate operator precedence (* binds tighter than +) in docs.
Example
Input
1 + 2 * 3
Output
7 (number)
Evaluation is limited to literals plus arithmetic and string concatenation; no user code is executed, so there is no injection risk.
Frequently asked questions
Why not just use eval?
eval would execute arbitrary code in your browser (network requests, DOM access) with uncontrollable risk. The hand-written parser only supports literals and arithmetic — limited but safe.
Which syntax is supported?
Numbers (decimals and scientific notation), single or double quoted strings, true / false / null, arrays [1, 2], objects {a: 1} (keys may be quoted), unary +/- and binary + - * / %, arbitrary parentheses, plus string concatenation with +.
What throws an error?
Variables, function calls, assignments (=), template literals, arrow functions, new, member access and semicolons all throw unsupported-expression; division by zero throws division-by-zero.
How do I read the result type?
The preview is "JSON value (type)", e.g. 7 (number), "ab" (string), [1,2] (array). The type comes from the actual evaluated value, not a guess.
Keywords:jsevalexpression evaluator