capture2tls.
capture2tls turns HTTP/1.1 or HTTP/2 requests copied from Charles Proxy into ready-to-run tls_client or curl_cffi sessions. It preserves the subtle request characteristics that generic generators drop—including header order and protocol selection.
Architecture
Small boundaries. Explicit behavior.
A format detector selects the correct request parser.
A normalized request model separates method, URL, headers, cookies, and body.
The generator emits readable Python instead of an opaque runtime wrapper.
Only the standard library is required to run the converter.
Implementation
The important path, in code.
A representative excerpt showing the project's approach. The complete implementation and history remain available in the public repository.
session = tls_client.Session( client_identifier="okhttp4_android_13", random_tls_extension_order=True,)headers = {"Accept": "application/json", "User-Agent": user_agent}session.header_order = list(headers.keys())session.force_http1 = Trueresponse = session.get(url, headers=headers, cookies=cookies)Capabilities
Converts 95%+ of captures without manual correction
Parses HTTP/1.1 and HTTP/2 pseudo-headers
Separates cookies into an explicit session dictionary
Detects JSON and form request bodies
Preserves header order and protocol intent