When you need to inspect, modify, or replay HTTP(S) traffic, few tools are as powerful and flexible as mitmproxy.
It's open-source, scriptable in Python, and works seamlessly as a man-in-the-middle proxy.
π What Is mitmproxy?β
mitmproxy is an interactive HTTPS proxy that lets you:
- Inspect requests/responses in real time
- Intercept and modify traffic on the fly
- Replay, record, or craft custom flows
- Run in terminal, web UI, or as a headless server
It acts as a transparent layer between the client and the server, giving you full control over the network.
π§ Why You Should Use Itβ
1. Debug Any Clientβ
Works with browsers, mobile devices, CLI tools, or backend services. Just set it as the proxy β instantly view traffic.
2. Full HTTPS Interceptionβ
Install the mitmproxy CA cert on your device and decrypt SSL traffic easily. Perfect for debugging encrypted APIs.
3. Modify Responses On the Flyβ
Rewrite headers, JSON payloads, or entire responses interactively. Great for:
- Mocking backend features
- Testing error scenarios
- Speeding up frontend development without changing backend code
4. Automate with Pythonβ
Use mitmproxy add-ons to script complex behaviors:
# example: force 500 errors for specific endpoints
def response(flow):
if "/api/test" in flow.request.pretty_url:
flow.response.status_code = 500
5. Record & Replay Trafficβ
Capture sessions once and replay them repeatedly β ideal for load testing, regression testing, or demos.
6. Open Source & Lightweightβ
No telemetry, no vendor lock-in. Runs locally, integrates easily into dev environments and CI setups.
π§ͺ Common Use Casesβ
- Debugging mobile apps without modifying them
- Overwriting API responses for local development
- Inspecting browser network traffic in depth
- Testing error handling in frontend apps
- Capturing traffic from IoT devices
β‘ Quick Startβ
brew install mitmproxy # macOS
mitmproxy # start interactive proxy on :8080
Then set your browser or device to use http://localhost:8080
as HTTP/HTTPS proxy and install the CA certificate from http://mitm.it.
π Final Thoughtsβ
mitmproxy is like a debugger for the network layer. Whether youβre a frontend dev, backend engineer, or security tester, it gives you total visibility and control over HTTP(S) traffic β without relying on external services.
π mitmproxy.org
π‘ Tip: Pair mitmproxy
with your browser devtools or mobile simulator for rapid iteration and powerful debugging.