Steve Pellegrin
April 10, 2011

Using Adblock Plus filter lists with BFilter

I have written a Perl script that converts Adblock Plus filters into BFilter patterns that can be added to urls.local. Using the companion shell script and cron, you can keep your copy of BFilter up-to-date.

Here's all you need to do:

You should edit both the filter and shell scripts to make sure that the first line correctly points to Perl and BASH on your system. Currently, they use /usr/bin/perl and /usr/local/bin/bash. You may also want to change some of the configuration parameters at the top of each script.

Special thanks to Ádám Fitz for his help debugging some issues with the filter script.

Changes as of 1/1/2011:

Ádám has some utility scripts for including/excluding the Adblock Plus lists via KDE or GTK on Ubuntu/Debian. If you can read German, you can learn more here.

Thanks, Ádám!

vadim s. sabinich has translated this page into Russian. Спасибо, Vadim!

Stephen Poole has written a cmd file (replaces the shell script) for people running bfilter on Windows. Ta, Stephen!

Be sure to read his comments (in the cmd file) regarding the difficulty of restarting bfilter on Windows.

daonlyfreez has created an equivalent script for AutoHotkey. He/she says:

For Windows, I created a q&d AutoHotkey script. If you do not know AutoHotkey, it's a FOSS scripting/micro-programming option for Windows. You can create an executable from script (~250k). Users won't need Perl (or wbat). This is the code. It does what the Perl script and the cmd/bat do together.

Thanks for the contribution, whoever and wherever you are. :-)

Configuring the Filter script

The filter script accepts an Adblock Plus filter list on STDIN and emits a list of BFilter patterns on STDOUT.

There are parameters in the script for:

Configuring the Shell script

The shell script copies the current version of an Adblock Plus filter list to a temporary file, then creates a new version of urls.local by using cat to merge this file and the contents of (if it exists).

If you currently have your own BFilter patterns in the file urls.local, rename the file to

There are parameters in the script for:

Valid HTML 4.01 Transitional

Powered by Apache