JA4 TLS Fingerprinting for Web Scrapers: Fixing Python and Node.js ClientHello Leaks
Swapping HTTP headers or routing traffic through residential proxies will not stop an edge firewall from spotting a scraper on packet one. Before your HTTP method or User-Agent string is parsed, the TLS termination layer inspects your ClientHello, counts offered cipher suites and extensions, reads ALPN tokens, and computes a JA4 fingerprint.
We measured requests, httpx, Node.js 24 (fetch and node:https), curl_cffi, and tls-client side by side against headless Chrome 158 on https://tls.peet.ws/api/all. Below are the exact handshake diffs, a programmatic JA4 parser you can run in CI, and an async TieredFetcher that handles clean pages over curl_cffi and escalates only challenge responses to Playwright.
How JA4 turns a ClientHello into a deterministic signal
Under JA3, anti-bot rules hashed TLS fields in the order sent on the wire. Once Chromium introduced TLS extension permutation in Chrome 110, identical browser binaries produced a different ja3_hash on almost every TCP connection. In three fresh launches of Chrome 158.0.8127.89 on macOS, ja3_hash shifted every run (f67731049e8d, cbc34cbfd9b7, 9c671720b420), while the FoxIO JA4 string stayed identical:
t13d1517h2_8daaf6152771_cb7bf5808d99

JA4 strips GREASE placeholders and sorts both cipher suites (JA4_b: 8daaf6152771) and non-SNI/non-ALPN extensions (JA4_c: cb7bf5808d99) before taking truncated 12-hex SHA-256 hashes. Signature algorithms remain in original order inside JA4_c. Meanwhile, the 10-character JA4_a prefix exposes protocol (t TCP vs q QUIC), TLS version (13), SNI presence (d), cipher count (15), extension count (17), and primary ALPN token (h2).
Because sorting defeats extension shuffling, security stacks rely on it at scale: Cloudflare JA4 Signals joins the fingerprint with hourly global traffic ratios, and AWS WAF lets rules aggregate rate limits directly by ja4Fingerprint even when scrapers rotate client IPs.
Polyglot benchmark: Node.js v24 and Python vs. Chrome 158
Many multi-language scraping teams assume Node.js fetch or Python httpx(http2=True) emits a modern transport profile. Running a quick Node probe (node_probe.mjs) alongside Python HTTP clients against https://tls.peet.ws/api/all shows why both fail immediately:
// node_probe.mjs (Node.js v24.16.0)
import https from 'node:https';
const ECHO_URL = 'https://tls.peet.ws/api/all';
const fetchData = await (await fetch(ECHO_URL)).json();
console.log('node fetch :', fetchData.http_version, fetchData.tls.ja4, fetchData.tls.ja3_hash.slice(0, 12));
https.get(ECHO_URL, (res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const d = JSON.parse(raw);
console.log('node:https :', d.http_version, d.tls.ja4, d.tls.ja3_hash.slice(0, 12));
});
});

Here are the full measured signatures captured on macOS (Node.js v24.16.0, Python 3.15.2, requests 2.34.2, httpx 0.29.0, curl_cffi 0.17.0, tls-client 2.0.0, and Google Chrome 158.0.8127.89):
| Client stack | Negotiated HTTP | tls.ja4 |
tls.ja3_hash |
Akamai H2 hash |
|---|---|---|---|---|
Chrome 158.0.8127.89 (baseline) |
h2 |
t13d1517h2_8daaf6152771_cb7bf5808d99 |
Rotates (f67731049e8d, cbc34cbfd9b7, 9c671720b420) |
52d84b11737d |
Node.js v24.16.0 fetch (undici) |
HTTP/1.1 |
t13d5212h1_b262b3658495_8e6e362c5eac |
d67b094811e5 |
none |
Node.js v24.16.0 node:https |
HTTP/1.1 |
t13d5211_b262b3658495_8e6e362c5eac |
944d1e1858cd |
none |
Python requests 2.34.2 |
HTTP/1.1 |
t13d1712h1_ab0a1bf427ad_581742d1f3c4 |
48bdbfeea1fc |
none |
Python httpx 0.29.0 (http2=True) |
h2 |
t13d1712h1_ab0a1bf427ad_e44827223d20 |
72d7d4e38c1a |
29e6a0e9b360 |
curl_cffi 0.17.0 (chrome / chrome152_macos) |
h2 |
t13d1517h2_8daaf6152771_cb7bf5808d99 |
Rotates (1ac3d4a9aac0, de0da3269b68) |
52d84b11737d |
curl_cffi 0.17.0 (firefox155) |
h2 |
t13d1517h2_8daaf6152771_3cbfd9057e0d |
424f6d9c8b89 |
6ea73faa8fc5 |
curl_cffi 0.17.0 (safari260) |
h2 |
t13d2014h2_a09f3c656075_d0a99439f9b1 |
6618231821d2 |
c52879e43202 |
tls-client 2.0.0 (chrome_152, random ext) |
h2 |
t13d1517h2_8daaf6152771_cb7bf5808d99 |
Rotates (15a508d912e4, 54e1042bca1b) |
52d84b11737d |
Three leaks stand out immediately from this dataset:
- Node.js OpenSSL bloat: Both
fetchandnode:httpsadvertise 52 cipher suites (b262b3658495) compared to Chrome’s 15, andnode:httpsomits ALPN altogether (t13d5211_...with no trailing protocol pair). httpx(http2=True)ALPN split: Enablinghttp2=Trueinhttpxupgrades the connection toh2(1:4096;2:0;4:65535;5:16384;3:100;6:65536|16777216|0|m,a,s,p), yet its TLSClientHellostill yieldst13d1712h1because OpenSSL presentshttp/1.1beforeh2in ALPN.tls-clientorder and UA traps: Callingtls_client.Session(client_identifier="chrome_152")without headers emitsUser-Agent: tls-client/2.0.0while sending Chrome’s JA4. Omittingrandom_tls_extension_order=Truefreezesja3_hashat2d25c56381929cc91bc97631a0a46f58across consecutive runs, making it trivial for order-sensitive checks to cluster.
Parsing and diffing JA4 strings in CI
Rather than manually inspecting hashes after every package update, parse a_b_c fields programmatically and fail CI builds when your HTTP client drifts from the target browser baseline. Notice that the regex below accepts 0–2 characters in the ALPN slot so empty-ALPN strings like node:https’s t13d5211_... parse cleanly without throwing.
Save ja4_diff.py:
import argparse
import re
import sys
from curl_cffi import requests as cffi
CHROME_BASELINE_JA4 = "t13d1517h2_8daaf6152771_cb7bf5808d99"
ECHO_URL = "https://tls.peet.ws/api/all"
JA4_RE = re.compile(
r"^(?P<proto>[tqd])(?P<tls>\d{2}|00)(?P<sni>[di])"
r"(?P<ciphers>\d{2})(?P<extensions>\d{2})(?P<alpn>[a-z0-9]{0,2})_"
r"(?P<cipher_hash>[0-9a-f]{12})_(?P<ext_hash>[0-9a-f]{12})$"
)
def decode_ja4(ja4: str) -> dict[str, str | int]:
match = JA4_RE.match(ja4.strip())
if not match:
raise ValueError(f"Unrecognized JA4 string: {ja4!r}")
parts = match.groupdict()
return {
"protocol": parts["proto"],
"tls_version": parts["tls"],
"sni": parts["sni"],
"cipher_count": int(parts["ciphers"]),
"extension_count": int(parts["extensions"]),
"alpn": parts["alpn"] or "none",
"cipher_hash": parts["cipher_hash"],
"ext_hash": parts["ext_hash"],
}
def diff_ja4(candidate: str, reference: str) -> list[str]:
cand = decode_ja4(candidate)
ref = decode_ja4(reference)
fields = (
"protocol",
"tls_version",
"sni",
"cipher_count",
"extension_count",
"alpn",
"cipher_hash",
"ext_hash",
)
return [f"{k}: {cand[k]} != {ref[k]}" for k in fields if cand[k] != ref[k]]
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--impersonate", default="chrome152")
parser.add_argument("--baseline", default=CHROME_BASELINE_JA4)
args = parser.parse_args()
live = cffi.get(ECHO_URL, impersonate=args.impersonate, timeout=20).json()["tls"]["ja4"]
diffs = diff_ja4(live, args.baseline)
if diffs:
print(f"[FAIL] {args.impersonate} drifted from baseline ({live}):")
for line in diffs:
print(f" - {line}")
sys.exit(1)
print(f"[PASS] {args.impersonate} matches JA4 baseline: {live}")
Running diff_ja4 against our measured node v24.16.0 node:https capture immediately surfaces all five structural mismatches (cipher_count: 52 != 15, extension_count: 11 != 17, alpn: none != h2, plus both hash diffs), while curl_cffi chrome152 exits 0.
Hardening curl_cffi and tls-client in production
Between curl_cffi (BoringSSL via curl-impersonate) and tls-client (Go uTLS via shared library), curl_cffi gives Python scrapers a safer baseline:
- Header parity:
curl_cffiinjects all 14 matching Chrome navigation headers (sec-ch-ua,sec-ch-ua-mobile,sec-ch-ua-platform,upgrade-insecure-requests,sec-fetch-*,priority, andaccept-language) automatically. Withtls-client, you must manage browser headers yourself. - Native event loop:
curl_cffi.requests.AsyncSessionintegrates directly withasyncio, whereastls-clientdispatches blocking Go calls through worker threads. - Avoid synthetic
ja3=strings: Manually assemblingja3=+extra_fp=incurl_cffirarely reaches Chrome’s full 17-extension signature; always prefer built-inimpersonate=profiles (chrome152,chrome152_macos,firefox155) pinned to your release lockfile. - Protocol parity: When scraping HTTP/3 endpoints,
curl_cffisupportshttp_version="v3"(verified returning200over HTTP/3 oncloudflare-quic.com), whereas Pythontls-client 2.0.0exposes HTTP/1.1 and HTTP/2 only.
Building an async TieredFetcher (curl_cffi -> Playwright)
Raw TLS impersonation solves the wire handshake, yet cannot solve Turnstile scripts or DOM-based bot checks. Spawning Playwright Chromium for every URL wastes RAM when most targets return JSON or plain HTML over curl_cffi.
A cleaner architecture tries curl_cffi.requests.AsyncSession first, checks status codes and Cloudflare challenge markers, and lazy-launches headless Chromium only for URLs that demand full JavaScript execution:

import asyncio
from curl_cffi import requests as cffi
from playwright.async_api import async_playwright
CHALLENGE_MARKERS = (
"Just a moment...",
"cf-turnstile",
"challenge-platform",
"Attention Required! | Cloudflare",
)
class TieredFetcher:
def __init__(self, impersonate: str = "chrome152", max_concurrency: int = 4):
self.impersonate = impersonate
self.sem = asyncio.Semaphore(max_concurrency)
self._session = None
self._playwright = None
self._browser = None
async def __aenter__(self):
self._session = cffi.AsyncSession(impersonate=self.impersonate)
await self._session.__aenter__()
return self
async def __aexit__(self, exc_type, exc, tb):
if self._session is not None:
await self._session.__aexit__(exc_type, exc, tb)
if self._browser is not None:
await self._browser.close()
if self._playwright is not None:
await self._playwright.stop()
async def _ensure_browser(self):
if self._browser is None:
self._playwright = await async_playwright().start()
self._browser = await self._playwright.chromium.launch(headless=True)
return self._browser
@staticmethod
def _needs_browser(status: int, body: str) -> bool:
if status in (403, 429, 503):
return True
return any(marker in body for marker in CHALLENGE_MARKERS)
async def fetch(self, url: str) -> dict:
async with self.sem:
resp = await self._session.get(url, timeout=20)
if not self._needs_browser(resp.status_code, resp.text):
return {
"url": url,
"tier": "curl_cffi",
"status": resp.status_code,
"bytes": len(resp.text),
}
browser = await self._ensure_browser()
page = await browser.new_page()
try:
nav = await page.goto(url, wait_until="domcontentloaded", timeout=30000)
html = await page.content()
return {
"url": url,
"tier": "playwright",
"status": nav.status if nav else 0,
"bytes": len(html),
}
finally:
await page.close()
async def main():
targets = [
"https://tls.peet.ws/api/all",
"https://httpbin.org/status/403",
]
async with TieredFetcher(impersonate="chrome152") as fetcher:
for result in await asyncio.gather(*(fetcher.fetch(u) for u in targets)):
print(result)
if __name__ == "__main__":
asyncio.run(main())
Verified locally, https://tls.peet.ws/api/all resolved on the curl_cffi tier (200, 0 browser launches) while https://httpbin.org/status/403 automatically triggered the Playwright tier. Whenever your Playwright fallback runs in production, keep its TLS, HTTP/2, Client Hints, and navigator properties aligned as shown in our Playwright and Node.js browser fingerprint consistency guide.
Beyond ClientHello: operational limits and Apify fallback

Even with identical BoringSSL JA4 hashes, Cloudflare JA4 Signals correlates fingerprints across its global network using metrics like browser_ratio_1h and cache_ratio_1h. Firing thousands of HTML-only GET requests per hour from one ASN triggers behavioral scoring regardless of TLS accuracy. And because FoxIO notes JA4 signatures shift about once a year when TLS stacks update while browser versions increment much faster, custom scrapers against platforms like TikTok or X demand constant profile updates, proxy hygiene, and anti-bot tuning.
When your pipeline needs clean social data without maintaining TLS clients or headless Chromium pools, call managed Apify actors directly from Python (pip install apify-client):
import os
from apify_client import ApifyClient
client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("novi/tiktok-scraper-ultimate").call(
run_input={
"keywords": ["python web scraping"],
"location": "US",
"maxItems": 20,
"outputFormat": "clean",
}
)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
print(item.get("id"), item.get("desc", "")[:80])
You can also target specific needs with Ultimate TikTok Scraper, Advanced Search TikTok API, or X.com Twitter API Scraper. New Apify accounts include free monthly credit so you can test schemas against your TieredFetcher fallback cost before migrating workloads.
References
- FoxIO-LLC/ja4: JA4+ Network Fingerprinting Repository
- FoxIO JA4 Technical Details (
JA4.md) - Cloudflare Blog: Advancing Threat Intelligence: JA4 fingerprints and inter-request signals
- AWS WAF Developer Guide: JA4 Fingerprint Matching and Rate-Based Rules
- lexiforest/curl_cffi: Python bindings for curl-impersonate
- bogdanfinn/tls-client and refraction-networking/utls