Skip to content
pubscout

http_parser

4.1.2, released 2 years ago by dart.dev

A platform-independent package for parsing and serializing HTTP formats.

WASM-readyQuiet but busy
$ flutter pub add http_parser
Source repository

What it does

It provides tools to parse and format HTTP dates, media types (like Accept and Content-Type headers), and other HTTP-related formats. It avoids referencing dart:io or dart:html so it can run on both browser and server.

AI-written summary of version 4.1.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to parse or serialize HTTP header values like Content-Type or media types.
  • You are writing a cross-platform web and server application that needs to handle HTTP formats without depending on dart:io.

Skip it when

  • You are looking for a full HTTP client library to make network requests.
  • You need WebSocket channel implementations (which have been moved to web_socket_channel).

Strengths

  • Platform-independent, works on both browser and server.
  • Reliable parsing and formatting for standard HTTP formats and media types.

Weaknesses

  • Limited in scope, strictly handles HTTP parsing and serialization formats rather than networking requests.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
4
import 'package:http_parser/http_parser.dart';

void main() {
  var mediaType = MediaType.parse('text/plain; charset=utf-8');
  print(mediaType.type); // text
  print(mediaType.subtype); // plain
  print(mediaType.parameters['charset']); // utf-8
}

Alternatives

Packages that do the same job and could replace http_parser.

  • pretty_http_logger

    Middleware logger for Dart's http package that prints requests and responses in a readable format.

  • http_client

    Platform‑independent HTTP client for browser, console and curl with SOCKS proxy support

  • graphql_2_rest

    Converts GraphQL queries into REST-compatible POST bodies for any HTTP client.

  • sync_http

    Synchronous HTTP client for Dart using RawSynchronousSockets.

Works with

Packages commonly used together with http_parser: ones it builds on, ones built on it, and its own family.