How to Get Lighthouse Scores from the Command Line and Compare Them with JSON
Lighthouse can be run from the command line, and it can save the results to a JSON file. In the saved JSON, categories holds the score of each category as a number from 0 to 1, and audits holds the result of each audit (check item). If you keep the JSON from before and after you fix a site and compare them with a small script, you can see how much each score went up, and which findings were fixed and which remain. This method is useful when you want to record the effect of accessibility or SEO improvements as score changes, without repeatedly comparing browser screens.
The test environment was Ubuntu 24.04, Node.js 22, Lighthouse 13.6.0 (the npm package), and jq 1.7. For Chrome, I used Chrome for Testing 153, which is included with Playwright 1.63.0. The test pages were served from a small server running in the test environment (localhost:8080). I only checked the two categories, accessibility and SEO. I did not test how to compare performance scores, the Lighthouse panel in Chrome DevTools, PageSpeed Insights, or results for a live site.
Run from the command line and save both JSON and HTML
According to the Lighthouse README, the Lighthouse CLI works with Node.js 22 or later. You can install it with npm install -g lighthouse, or run it with npx as shown below. Lighthouse automatically finds and uses an installed Chrome, but you can also specify the Chrome to use with the CHROME_PATH environment variable. The test environment did not have Chrome installed, so I set CHROME_PATH to the location of the Chrome for Testing bundled with Playwright before running it, as follows.
$ export CHROME_PATH=$(node -e "console.log(require('playwright').chromium.executablePath())")
For the comparison, I prepared the following page (before.html). The <html> element has no lang, the <img> has no alt, and the body text is a light gray (#bbbbbb) that is close to the white background. There is also no <meta name="description">.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>猫の手日記</title>
<style>
body { margin: 0 auto; max-width: 640px; font-family: sans-serif; }
.note { color: #bbbbbb; }
</style>
</head>
<body>
<h1>猫の手日記</h1>
<img src="/cat.png" width="320" height="180">
<p class="note">きょうの猫は、窓辺で昼寝をしていました。</p>
</body>
</html>
I ran Lighthouse on this page.
$ npx lighthouse http://localhost:8080/before.html --only-categories=accessibility,seo --output=json --output=html --output-path=./out/before --chrome-flags="--headless=new --no-sandbox" --quiet
exit: 0
$ ls out
before.report.html
before.report.json
The options used are as follows.
--only-categories: Limits the categories to check. Here, only accessibility (accessibility) and SEO (seo).--output: The output format. You can choosejson,html, orcsv, and you can specify more than one.--output-path: The save location. If you specify two or more formats, the files are named with the given name plus.report.jsonor.report.html.--chrome-flags: Startup options passed to Chrome. Since this environment has no display, Chrome is started headless (without a screen), and--no-sandboxis also added.--quiet: Does not print progress logs.
The HTML file is a report meant to be opened and read in a browser. The JSON file is the one compared in this article.
Where the scores and findings are in the JSON
The scores are in categories.<category name>.score. Extracting them with jq gave the following.
$ jq '.categories | map_values(.score)' out/before.report.json
{
"accessibility": 0.53,
"seo": 0.82
}
The score shown in the HTML report is this value multiplied by 100, so accessibility is 53 and SEO is 82 (the same numbers appear in the images in the later sections). The JSON also contains the Lighthouse version (lighthouseVersion), the URL that was checked (requestedUrl), and the time the test ran (fetchTime). Even if you keep only the file, you can tell when it was measured and what was measured.
$ jq '.lighthouseVersion, .requestedUrl, .fetchTime' out/before.report.json
"13.6.0"
"http://localhost:8080/before.html"
"2026-11-13T06:12:09.664Z"
The results of each audit are in audits, keyed by the audit name (such as image-alt). According to the explanation of the result JSON, the score of each audit is also a number from 0 to 1. However, audits that do not get a score (those whose scoreDisplayMode is informative, manual, notApplicable, or error) have score set to null. So I extracted only the scored audits whose score is below 0.9. The 0.9 value is the lowest score that Lighthouse's source (shared/util.js) treats as a pass, defined as PASS_THRESHOLD.
$ jq -r '.audits[] | select(.score != null and .score < 0.9 and (.scoreDisplayMode == "binary" or .scoreDisplayMode == "numeric" or .scoreDisplayMode == "metricSavings")) | "\(.id)\t\(.score)\t\(.title)"' out/before.report.json
color-contrast 0 Background and foreground colors do not have a sufficient contrast ratio.
html-has-lang 0 `<html>` element does not have a `[lang]` attribute
image-alt 0 Image elements do not have `[alt]` attributes
landmark-one-main 0 Document does not have a main landmark.
meta-description 0 Document does not have a meta description
Five findings came up: the text and background do not have enough contrast (color-contrast), there is no lang (html-has-lang), there is no alt (image-alt), there is no <main> (landmark-one-main), and there is no meta description (meta-description).
The elements that were flagged are in each audit's details.items. For example, the contrast finding included the actual contrast ratio and the required ratio.
$ jq '.audits["color-contrast"].details.items[].node.explanation' out/before.report.json
"Fix any of the following:\n Element has insufficient color contrast of 1.91 (foreground color: #bbbbbb, background color: #ffffff, font size: 12.0pt (16px), font weight: normal). Expected contrast ratio of 4.5:1"
A category's score is the weighted average of its audit scores. The weights are in the weight field under categories.<category name>.auditRefs. When I sorted the accessibility audits by weight from largest to smallest, image-alt had a weight of 10 and html-has-lang had a weight of 7. For before.html, five audits failed, including image-alt (weight 10) and html-has-lang (weight 7), and the accessibility score was 53.
$ jq -r '.categories.accessibility.auditRefs[] | select(.weight > 0) | "\(.id)\t\(.weight)"' out/before.report.json | sort -k2 -nr | head -5
meta-viewport 10
image-alt 10
aria-hidden-body 10
html-has-lang 7
document-title 7
A script that compares the JSON from before and after the fix
On the page after the fix (after.html), I fixed four of the findings. I changed it to <html lang="ja">, added alt to the <img>, darkened the text color to #595959, and added a <meta name="description">. I did not add <main> yet.
<html lang="ja">
...
<meta name="description" content="窓辺で昼寝をする猫の様子を書いた日記です。">
<style>
...
.note { color: #595959; }
</style>
...
<img src="/cat.png" width="320" height="180" alt="窓辺で昼寝をする猫のイラスト">
I ran the same options with --output-path=./out/after, and wrote a script (compare.mjs) that compares the two JSON files. It outputs the difference in each category's score and the audits whose pass/fail status changed.
// Usage: node compare.mjs before.json after.json
import { readFileSync } from 'node:fs';
const [a, b] = process.argv.slice(2).map((f) => JSON.parse(readFileSync(f, 'utf8')));
const pct = (s) => (s == null ? '-' : Math.round(s * 100));
console.log('カテゴリー 前 後 差');
for (const [id, cat] of Object.entries(b.categories)) {
const before = a.categories[id]?.score, after = cat.score;
const d = pct(after) - pct(before);
const diff = before == null ? '' : (d > 0 ? '+' : '') + d;
console.log(`${id.padEnd(16)} ${String(pct(before)).padStart(4)} ${String(pct(after)).padStart(4)} ${String(diff).padStart(4)}`);
}
// Scored audits (such as binary and numeric) whose pass/fail result changed, and those that remain later on
const scored = (au) => au.score != null && !['informative', 'manual', 'notApplicable'].includes(au.scoreDisplayMode);
const fixed = [], added = [], remain = [];
for (const [id, au] of Object.entries(b.audits)) {
const old = a.audits[id];
const failNow = scored(au) && au.score < 0.9;
const failOld = old && scored(old) && old.score < 0.9;
if (failOld && !failNow) fixed.push(id);
else if (!failOld && failNow) added.push(id);
else if (failOld && failNow) remain.push(id);
}
console.log(`\n消えた指摘: ${fixed.join(', ') || 'なし'}`);
console.log(`増えた指摘: ${added.join(', ') || 'なし'}`);
console.log(`残っている指摘: ${remain.join(', ') || 'なし'}`);
When I ran it, the output was as follows.
$ node compare.mjs out/before.report.json out/after.report.json
カテゴリー 前 後 差
accessibility 53 95 +42
seo 82 100 +18
消えた指摘: color-contrast, html-has-lang, image-alt, meta-description
増えた指摘: なし
残っている指摘: landmark-one-main
The four findings I fixed disappeared, accessibility went from 53 to 95, and SEO went from 82 to 100. landmark-one-main, which I had not fixed yet, shows up under "remaining findings". When I measured the page before the fix three times in a row, all three runs gave 53 and 82. Since re-measuring did not change the scores, the difference can be attributed to the page fix.
Fix the remaining finding and compare again
In after-main.html, I wrapped everything from <h1> to the body text in <main>.
<body>
<main>
<h1>猫の手日記</h1>
<img src="/cat.png" width="320" height="180" alt="窓辺で昼寝をする猫のイラスト">
<p class="note">きょうの猫は、窓辺で昼寝をしていました。</p>
</main>
</body>
Compared with the previous result (after.report.json), the last finding was also fixed, and accessibility became 100.
$ node compare.mjs out/after.report.json out/after-main.report.json
カテゴリー 前 後 差
accessibility 95 100 +5
seo 100 100 0
消えた指摘: landmark-one-main
増えた指摘: なし
残っている指摘: なし
In the HTML report, the score circles changed as follows.

When comparing, run both measurements with the same options, especially --only-categories.
Pass the results straight to jq without saving a file
If you only need to see the scores, you can use --output-path=stdout to print the JSON to standard output and pipe it directly to jq.
$ npx lighthouse http://localhost:8080/after-main.html --only-categories=accessibility,seo --output=json --output-path=stdout --chrome-flags="--headless=new --no-sandbox" --quiet | jq '.categories | map_values(.score * 100)'
{
"accessibility": 100,
"seo": 100
}





