LazSwitchHosts
A lightweight hosts management tool built with Lazarus (Free Pascal). Features syntax highlighting, find & replace with regex, multi-select editing, and a plugin-based editor engine. Less than 7MB memory usage — 98% less than SwitchHosts. Apache-2.0 licensed, cross-platform (Windows/Linux/macOS).
- Active · last change 7-20-2026
- ★ 1 on GitHub
README
LazSwitchHosts
A lightweight hosts management tool built with Lazarus (Free Pascal), providing a graphical interface for quickly switching between different hosts configurations.
中文版 | A native desktop application designed for users who pursue extreme performance and simplicity, serving as an alternative to the local hosts management functionality of SwitchHosts.
🖥️ Windows Screenshots
SwitchHosts uses approximately 308MB of RAM (Working Set).
LazSwitchHosts uses less than 7MB of memory — extremely lightweight.
The built-in Find & Replace dialog supports regular expressions and case-insensitive matching.
🎯 Core Advantages
- Tiny footprint: Under 6MB compiled, under 2MB with UPX compression — a single standalone executable with zero dependencies
- Minimal memory: Less than 7MB at runtime, saving 98% compared to SwitchHosts (~308MB)
- Instant startup: Native compilation, no framework loading overhead
- Native experience: LCL native UI, fast and responsive
- Plugin-based editor: Reusable editor engine architecture supporting Ctrl+D multi-select editing, syntax highlighting, and find & replace
🔍 Features
- Graphical interface: Cross-platform desktop app based on LCL
- Quick switching: One-click switching between different hosts configurations
- Configuration management: Add, edit, delete, and drag-to-reorder hosts entries
- Syntax highlighting: Color-coded IP addresses, hostnames, and comments
- Multi-select editing: Ctrl+D to select matching words one by one for synchronized replacement
- Find & replace: Supports regular expressions and case-insensitive matching
- Line operations: Ctrl+C/X/V copies/cuts/pastes entire lines when no selection is active
- Keyboard shortcuts: Ctrl+S to save, Ctrl+/ to toggle comment, Ctrl+Z/Y for undo/redo
- System tray: Minimize to tray, double-click to restore
Environment Requirements
- Supported platforms: Windows, Linux, macOS
- Development environment: Lazarus IDE
- Dependencies: BGRABitmapPack (install via Lazarus Online Package Manager)
Environment Variables
LAZ_SWITCHHOSTSDIR: Custom configuration directory (default:~/.SwitchHosts)LAZ_HOSTSFILENAME: Custom hosts file path (default: system hosts file path)
Project Structure
LazSwitchHosts/
????????? lazswitchhosts.lpr # Program entry point
????????? unitmain.pas # Main window UI and event handling
????????? unitconfigmanager.pas # Configuration manager (JSON)
????????? unitutils.pas # Platform utility functions
????????? unithostshighlighter.pas # Hosts syntax highlighter
????????? unitsearchdialog.pas # Find & replace dialog
????????? unitmultiselect.pas # Multi-select (Ctrl+D)
????????? unittoggleswitch.pas # Toggle switch controlFeature Limitations
This project follows a minimalist design philosophy and is not a full replacement for SwitchHosts. The following features are not supported:
- Remote hosts configuration (URL-based)
- Sub-folder configuration management
- Proxy settings
- Configuration change history backup
Credits
- Icons: https://www.iconfont.cn/collections/detail?cid=19977
- BGRABitmapPack - MPL 2.0 / LGPL v3
- SynEdit - MIT
- LCL - LGPL v2.1
License
This project is licensed under the Apache License 2.0 — see the LICENSE file for details.

