PAC File Tester

Test a proxy.pac against a list of URLs, with syntax checks and an old/new diff. Runs offline.

日本語

Download (free)

The whole tool is one file, pac-tester.html. Nothing to install and no network access, so it works on locked-down work PCs and on machines with no internet connection.

The tool's screen is in Japanese. The key labels are below.

Test FindProxyForURL offline

More features
  • The host name is taken from each URL for you
  • You set the DNS answers (a host-to-IP table), the value of myIpAddress() and the date and time the script sees
  • Colour-coded results: each distinct return value gets a colour and a count; click one to filter. alert() output, errors and timeouts show on the row they belong to. Export to CSV
  • The 14 helpers: isInNet, shExpMatch, dnsDomainIs, weekdayRange, timeRange and the rest (see the guide)
  • Infinite loops can't freeze it: each URL is cut off after 0.2 seconds

PAC file debugger: what the checks find

The checks parse the script (with acorn) without running it, and point to the line.

What the checks look for

The checks are approximate and will not catch every mistake.

  • No FindProxyForURL, a wrongly capitalised name, the wrong number of parameters, or two definitions
  • Full-width (CJK) spaces and punctuation, and zero-width spaces, pasted into code. An error in code, a warning inside strings, ignored in comments
  • Unbalanced ( ) { } [ ] and unclosed quotes, with the line where they open and where they go wrong
  • Paths where the function can end without a return, and return values in the wrong format (, instead of ;, "PROXY" with no host, a port out of range)
  • shExpMatch patterns that can never match, such as ".example.com" without *, a scheme in a host pattern, or a URL pattern missing its trailing /
  • Shadowed rules: an earlier if (…) return …; whose pattern already covers a later one, so the later rule is never reached
  • Suspicious helper calls: a non-contiguous isInNet mask, dnsDomainIs without the leading dot, lower-case weekdayRange days, timeRange(22, 6)

How to use it

  1. Download pac-tester.html and double-click it
  2. Paste your PAC into the left-hand box, or drag and drop a .pac file onto the page
  3. List the URLs to test in the right-hand box, one per line. Results and check messages update as you type
Label on screenMeaning
PAC ファイルPAC file (paste here)
テストする URLURLs to test
結果Results
構文・ロジックのチェックSyntax and logic checks
評価の設定Evaluation settings (click to expand)
差分モードDiff mode
Reading the Japanese screen (all labels)
Label on screenMeaning
評価するEvaluate now (Ctrl+Enter). Normally not needed: it re-evaluates 400 ms after you stop typing
差分モードDiff mode
見本Load the sample PAC, URLs and settings
ライセンスAbout this tool and the bundled library's license
PAC ファイルPAC file (paste here)
開くOpen a file
旧 PAC(いまの版)/新 PAC(変更後)Old PAC (current) / New PAC (changed), in diff mode
旧を写すCopy the old PAC into the new box
PAC と URL 一覧も、このブラウザに保存するAlso save the PAC and URL list in this browser (off by default)
構文・ロジックのチェックSyntax and logic checks. Click a message to jump to its line
エラー/注意/参考Error / Warning / Info
問題は見つかりませんでしたNo problems found
shExpMatch のパターン一覧List of every shExpMatch pattern in the file
テストする URLURLs to test (one per line; lines starting with # are comments)
.txt を開く/.txt で保存Open / save the URL list as a .txt file
評価の設定Evaluation settings (click to expand)
ホスト名と IP アドレスの対応表Host-to-IP table, used instead of DNS
myIpAddress() が返す IP アドレスIP address returned by myIpAddress()
評価に使う日時/いまの日時を使うDate and time the script sees / use the current date and time
UTC との時差UTC offset
https の URL は、パスとクエリを除いて渡すStrip the path and query from https URLs (on by default, as Chrome and Edge do)
結果Results
URL・結果で絞り込みFilter by URL or result
変わった行だけ/エラー・注意だけChanged rows only (diff mode) / Errors and warnings only
CSV で保存Save as CSV
タイムアウト/エラー/変更Timeout / Error / Changed
undefined(戻り値なし)undefined (the function returned nothing)
PAC に渡す URLThe URL actually passed to FindProxyForURL (shown when the https path was stripped)

Check messages and CSV column headings are also in Japanese. Each message shows its line number and severity.

On first launch it shows a sample PAC, URL list and host table that use only example domains (the sample's comments are in Japanese).

Common questions this answers

How do I test a PAC file without deploying it?

Paste it into the tester and list the URLs you care about. You don't need a web server or a proxy.

How the URL is passed

The tester calls FindProxyForURL(url, host) for each one: host is the host name from the URL, in lower case and without the port. A line without a scheme is treated as http://.

How do I debug FindProxyForURL?

Put alert("…") calls in the script: their output appears on the result row for that URL. Script errors and timeouts also show per URL.

Why does dnsResolve or isInNet behave differently here?

A web page can't do DNS lookups, so the tester uses your host-to-IP table instead. A host that isn't in the table can't be resolved: dnsResolve returns null and isResolvable and isInNet return false.

IP addresses, localhost and IPv6

An IP address in the URL is used as is, and localhost is 127.0.0.1 unless the table says otherwise. Only IPv4 is supported, and Microsoft's IPv6 extensions (isInNetEx, dnsResolveEx and so on) raise an error.

What URL format do I use for a local .pac file?

For this tester, none: open or drop the file. A local file URL looks like file:///C:/proxy/proxy.pac on Windows (RFC 8089, E.2), but Windows' WinHTTP supports only http: and https: PAC URLs.

Why does a path rule not match https URLs?

Chrome and Edge pass only https://host/ to the PAC for https URLs, without the path or query. The tester does the same by default.

Your PAC stays on your machine and runs in a sandbox

pac-tester.html never connects to any server. The PAC runs in a Worker inside a sandboxed iframe, separate from the page.

More on safety
  • Its Content-Security-Policy blocks network requests as well
  • pac-tester.html includes everything it needs, including the parser library (acorn). PAC files with internal host names are safe to paste
  • A PAC is a program, so it runs separately from the page. It can't touch the page, its storage, or the network
  • By default your PAC isn't saved in the browser either (you can opt in)
  • pac-tester.html contains no ads and no analytics (ads appear only on this page and the guide)

Guide: helper function reference, common mistakes, diff mode, FAQ

By the same author: query Active Directory without RSAT from PowerShell → ADSearch