Package selection guidance compiled from public package information, community data, and project usage.
A Dio interceptor that enhances debugging by pretty-printing HTTP requests and responses in the console with clear formatting. It helps developers quickly inspect data flow, headers, and status codes during development. The package integrates seamlessly with Dio, a popular HTTP client for Dart, and supports all major platforms including Android, iOS, Web, macOS, Windows, and Linux. Ideal for troubleshooting API interactions without requiring external tools.
Use cases
Debugging API calls in development
Inspecting request/response payloads
Monitoring HTTP headers and status codes
Improving developer productivity during API integration
Projects where real-time console logs are beneficial
Considerations
Not recommended for production builds
May impact performance slightly due to logging
Requires manual configuration to disable in release mode
Logs may expose sensitive data if not filtered
Limited to console output, no file or external logging support
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
A simple Dio interceptor for pretty printing the HTTP request/response (using the awesome
package Logger) to be printed in the console for easier debugging and sharing.
Different content types are supported and pretty printed such as:
application/json
application/x-www-form-urlencoded
text/html
Getting started
1- Install the package in your project:
flutter pub get dio_http_formatter
or if not for Flutter:
pub get dio_http_formatter
2- Add the interceptor to your Dio instance like:
final _dio = Dio();
_dio.interceptors.add(HttpFormatter());
Dio Version Map
For a certain version of Dio, use the following table to find the correct version of this package to use:
Dio Version
Package Version
4.x.x
2.x.x
5.x.x
3.x.x
Options
Below are the optional parameters that can be specified for the formatter to customize what and how the HTTP request and response is printed.
Property
Type
Default Value
includeRequest
bool
true
includeRequestHeaders
bool
true
includeRequestQueryParams
bool
true
includeRequestBody
bool
true
includeResponse
bool
true
includeResponseHeaders
bool
true
includeResponseBody
bool
true
logger
Logger
PrettyPrinter()
loggingFilter
LoggingFilter
null
Logging Filter
The HTTPFormatter has support for filtering whether to log a request/response or not. For example:
final dio = Dio();
dio.interceptors.add(
HttpFormatter(
loggingFilter: (request, response, error) {
// We don't want to print the request/response when 201 is returnedif (response?.statusCode == 201) {
returnfalse;
}
// Otherwise, the logs should printreturntrue;
},
),
);
[!WARNING] httpLoggerFilter is now deprecated and it's highly encouraged to move to the new loggingFilter. httpLoggerFilter will be removed in the next major version.