JavaScript Validator

A deploy fails with Unexpected token on line 212 of a file you did not write. Paste the script, set the ES version your build targets, then read every JSHint error and warning with its line and column. Checking runs inside this tab.

Environment
Source type
Extra rules

Source

0 linesCtrl + Enter checks now. Your code stays in this tab.

Report

Nothing checked yet Paste code or press Load sample. Findings show here and as gutter marks in the editor.

    Errors block the parse. Warnings point at a known trap.

    Every finding carries a JSHint code. The first letter tells you how urgent the fix is.

    PrefixMeaningExample
    EThe source breaks the grammar of the ES version you picked, or breaks a rule the language enforces, such as reassigning a const. Fix these first.E019 Unmatched '{'.
    WThe code parses. The pattern behind the warning is a common source of bugs: loose equality, a missing semicolon, a name with no declaration.W117 'cart' is not defined.
    IRare notes about options or directives. Safe to read last.Option notices

    Codes you will meet most, with the usual fix

    CodeMessageUsual fix
    W033Missing semicolon.Add the semicolon. If your team writes without semicolons on purpose, watch lines starting with (, [ or a backtick, the three spots where automatic insertion goes wrong.
    W117'x' is not defined.Declare the name. If x is a host global such as document or process, switch Environment instead.
    W116Expected '===' and instead saw '=='.Use ===. Keep == null only where you mean to catch both null plus undefined.
    W084Expected a conditional expression and instead saw an assignment.if (total = 0) assigns zero. Write ===.
    W083Functions declared within loops referencing an outer scoped variable...Change var to let in the loop header, or move the callback out of the loop.
    W098'x' is defined but never used.Delete dead code. Untick Unused variables for files exposing functions through globals.
    W119'x' is only available in ES6 (use 'esversion: 6').Raise ES version to match your build target, or transpile.
    E013Attempting to override 'x' which is a constant.Declare with let, or stop reassigning.
    E041Unrecoverable syntax error.JSHint stopped scanning. Fix the error listed right above this one, then check again.

    Reading the sample report line by line

    Load sample fills the editor with a short cart script. It looks finished. Five of its findings would reach users as bugs, the rest are hygiene. Here is the order worth fixing them in.

    1. Line 24, E013. TAX_RATE = 0.09 reassigns a constant. Browsers throw a TypeError the moment this line runs.
    2. Line 8, W084. if (total = 0) sets total to zero, the branch never runs, then the function returns "0.00" for every cart. No exception, no console message. The linter is the only thing pointing at this one.
    3. Lines 15 to 17, W083. With var i, every click handler reads i after the loop has finished, so buttons[i] is undefined at click time. Swap to let i and the warning goes away.
    4. Lines 17 and 23, W117. applyCoupon and cart have no declaration. If another script defines them, add /* global applyCoupon, cart */ at the top. If not, you found a typo before production did.
    5. Line 23, W116 twice. Loose == compares a number with a string, plus the if has no braces. Both rules come from the Extra rules boxes. Untick them and both findings disappear.
    6. Line 4, W033, and line 14, W098. A missing semicolon and a function nothing calls. Neither breaks this file.

    Settings above the editor change the verdict

    ES version
    Sets which syntax counts as legal. Under ES5 every arrow function, let, template literal or class produces W119. Pick the oldest target your bundler or browser list ships to, not the newest one your editor understands.
    Environment
    Browser predefines window, document, fetch, localStorage. Node.js predefines require, module, process, Buffer, __dirname. Both suits shared utility files. console exists in all three.
    ES module
    Allows import plus export at the top level. Off by default since a classic script tag rejects both. Greyed out under ES5.
    Extra rules
    Undeclared variables, unused variables, strict equality, braces on every block. Untick all four for a syntax-first pass. JSHint still reports its default warnings, W033 among them.

    Fix from the top, then check again

    1. Clear E codes first, top to bottom. One missing brace shifts how the parser reads every line below, so later errors often vanish after the first fix.
    2. If the list ends with E041, scanning stopped there. Lines past the stop point have no findings yet. Absence of findings below E041 says nothing about those lines.
    3. Settle W117 next. Each one is either a missing declaration, a wrong Environment, or a typo.
    4. Work through the remaining warnings. Click any finding to jump the editor cursor to its line.
    5. The report caps at 100 findings. Past the cap, fix the first batch, then check again.

    Which checker fits the job

    ToolBest forBlind spot
    This pageOne pasted snippet, a bug report, a script from a CMS field. Nothing to install.Fixed JSHint rule set, no project config, no plugins.
    node --check app.jsThe plain question "will this file load?", answered by the exact parser in your Node version.Syntax only. No warnings about undeclared names or loose equality.
    ESLint in the repoCommitted code, shared team rules, React or TypeScript plugins, autofix on save.Needs a config file before a single finding appears.
    tsc --noEmitType errors in TypeScript or checkJs projects.Ignores style rules unless paired with a linter.

    What a clean report does not prove

    JavaScript validator questions

    Globals, frameworks, minified files and where the scan stops.

    Is my code sent to a server?

    No. JSHint runs inside this browser tab. The page sends no request containing your source, and a reload clears the editor.

    Why does it say document or process is not defined?

    The Environment setting decides which globals exist. Browser covers document and window, Node.js covers process and require. Pick Both for shared files, or add a /* global name */ comment at the top for globals your own scripts define.

    Does it check JSX, Vue or TypeScript?

    No. JSHint reads plain JavaScript only. A JSX tag or a type annotation stops the scan with an error. Use ESLint with the React, Vue or TypeScript parser for those files.

    Why does every finding in my file say line 1?

    The file is minified onto a single line. Format it with the JavaScript Beautifier first, paste the result here, and line numbers become useful again.

    Is this the same as ESLint?

    No. JSHint is an older linter with a smaller fixed rule set. Both catch syntax errors, undeclared variables and loose equality. ESLint adds plugins, autofix and per-project configuration, so use ESLint for code in a repository.

    Do warnings mean the code is broken?

    Not always. A missing semicolon rarely breaks a file. An assignment inside an if condition (W084) or a callback created in a var loop (W083) usually does. Read the flagged line before dismissing a warning.

    Why are there no findings below a certain line?

    Either JSHint hit an unrecoverable syntax error (E041) and stopped, or the report reached its 100 finding cap. Fix the findings shown, then check again.