Home › Developer Tools › Luhn Algorithm Checker

Luhn Algorithm Checker

Check whether a number passes the Luhn (mod 10) test, or work out the check digit to append to it. Every doubled digit and the final sum are shown so you can follow, or teach, the algorithm.

Last updated:

Mode

Validate: the full number including its last (check) digit. Calculate: the number without the check digit.

Enter your values to see the result.
Advertisement
Advertisement

How to use the Luhn Algorithm Checker

  1. Choose a mode: validate a full number, calculate a check digit, or check a list.
  2. Type or paste the number. Spaces and hyphens are fine.
  3. Click Check (results also update as you type).
  4. Read the verdict and the correct check digit.
  5. Follow the working table to see each doubled digit and the total.

Worked example: 79927398713

Digit (left to right)79927398713
Double?×2×2×2×2×2check
Value718 → 99476916 → 7723

7 + 9 + 9 + 4 + 7 + 6 + 9 + 7 + 7 + 2 + 3 = 70, and 70 is divisible by 10, so the number is valid. Change any single digit and the sum is no longer a multiple of 10.

Doubling lookup table

Digit0123456789
Doubled, minus 9 if over 90246813579

Luhn and other check digit schemes

  • Luhn (mod 10, weights 2-1): payment cards, IMEI, NPI. Simple, catches all single-digit errors.
  • GS1 mod 10 (weights 3-1): UPC and EAN barcodes. Similar idea, different weights, see the Check Digit Calculator.
  • Mod 11: ISBN-10 and ISSN. Catches all single errors and all adjacent swaps, but needs an extra symbol (X) for 10.
  • Verhoeff and Damm: catch every adjacent transposition too, at the cost of lookup tables.

Frequently asked questions

How does the Luhn algorithm work?

Starting from the rightmost digit (the check digit) and moving left, double every second digit. If a doubled value is greater than 9, subtract 9. Add all the digits together. The number is valid when the total is a multiple of 10.

How do I calculate a Luhn check digit?

Take the number without its check digit, double every other digit starting with the rightmost one, subtract 9 from any result over 9, and add everything. The check digit is (10 − sum mod 10) mod 10. For 7992739871 the sum is 67, so the check digit is 3 and the full number is 79927398713.

Where is the Luhn algorithm used?

It is used for payment card numbers, IMEI numbers of mobile phones, US National Provider Identifiers, Canadian Social Insurance Numbers, and many loyalty and gift card numbers. It was created by IBM scientist Hans Peter Luhn and is described in ISO/IEC 7812-1.

Does passing the Luhn check mean a card number is real?

No. Luhn only detects typing mistakes. About one in ten random numbers passes, so a valid result says nothing about whether an account exists or is active.

Which errors does the Luhn check catch?

It catches every single-digit error and most swaps of two adjacent digits. It misses the swap 09 ↔ 90 and twin errors such as 22 ↔ 55, 33 ↔ 66 and 44 ↔ 77.

Why subtract 9 from doubled digits?

Subtracting 9 from a two-digit result is the same as adding its two digits together: 7 × 2 = 14, and 1 + 4 = 5 = 14 − 9. It keeps every value a single digit.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Check Digit CalculatorCalculate or validate check digits for UPC, EAN, GTIN, SSCC, ISBN, ISSN and mod 11 codes.Checksum CalculatorCompute 8-bit sum, two's complement LRC, XOR/BCC, NMEA, Fletcher and Internet checksums of bytes.IBAN ValidatorCheck an IBAN's mod-97 checksum, country and length, and see its bank code and account parts.Routing Number ValidatorCheck a US ABA routing number's checksum and format and see its Federal Reserve district.JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.SQL Formatter & BeautifierFormat, beautify or minify SQL queries for MySQL, PostgreSQL and more.JavaScript BeautifierFormat and beautify messy or minified JavaScript, or minify it.HTML FormatterBeautify and indent HTML code with a live preview.CSS FormatterBeautify CSS with indent controls and optional property sorting.XML FormatterBeautify, validate and minify XML with a collapsible tree view.ZIP File CreatorCompress files and folders into a ZIP.YAML Validator & FormatterValidate, format and minify YAML, and convert YAML to JSON or back.HTML MinifierMinify HTML: strip comments and whitespace safely and see how many bytes you save.CSS MinifierMinify CSS with csso or a built-in engine and see the size saved instantly.JavaScript MinifierMinify JavaScript with Terser: compress, mangle and see how many bytes you save.JSON MinifierMinify and validate JSON, sort keys and see exactly how many bytes you save.Code Diff CheckerCompare two code files side by side or unified, with syntax colors and changes highlighted.IPv6 Expander & CompressorExpand IPv6 addresses to full form or compress them per RFC 5952, one or many at once.GraphQL FormatterPretty-print and indent GraphQL queries, mutations and schemas, or minify them, instantly.CSS ValidatorValidate CSS: syntax errors, unknown properties and invalid values by line, plus auto-fix.Gzip Compress / DecompressGzip or deflate text and files, get Base64 output, and decompress Base64 or .gz files.JavaScript Syntax CheckerCheck JavaScript for syntax errors with line and column, for any ES version, script or module.JSON Schema ValidatorValidate JSON against a JSON Schema (draft-07, 2019-09, 2020-12) with clickable error paths.Markdown FormatterBeautify Markdown with Prettier: list markers, prose wrap, aligned tables and live preview.PHP FormatterBeautify PHP code with Prettier PHP: PSR-12 style, indent and brace options, syntax errors.TypeScript FormatterFormat TypeScript and TSX code with Prettier: width, tabs, semicolons and quotes options.XML MinifierMinify and validate XML: strip whitespace and comments, keep CDATA, see the size savings.C# FormatterBeautify C# code online: Allman or K&R braces, indent size and line width, clang-format option.HTML ValidatorCheck HTML for errors and warnings with line numbers, locally or with the W3C Nu checker.Java FormatterBeautify Java code online: indent size, brace style and line width, with clang-format option.JavaScript ObfuscatorObfuscate JavaScript with string encoding, renaming and control-flow flattening presets.Phone Number FormatterFormat and validate lists of phone numbers to E.164, international or national style.Python FormatterFormat Python code in Black/Ruff style: line length, quote style, indent, copy or download.Responsive Design CheckerPreview any website at phone, tablet, laptop and desktop sizes side by side, with rotate and zoom.Browser Compatibility CheckerSearch CSS, JavaScript and HTML features and see which browser versions support them.Core Web Vitals CheckerCheck real-user LCP, INP and CLS for any URL or site and see if it passes Core Web Vitals.Heading Structure CheckerPaste HTML to see its H1-H6 outline and catch missing H1s, multiple H1s and skipped levels.Website Hosting CheckerFind out who hosts a website: hosting provider, IP addresses, ASN, network owner and location.XSD ValidatorValidate XML against an XSD schema in your browser and see each error with its line number.Strftime Format BuilderBuild Python and C strftime format strings by clicking tokens, with a live preview and reference.Spam Word CheckerScan an email subject and body for spam trigger words, excess caps, exclamation marks and risky links.
See all 41 Code Formatters & Validators →