Retrofit vs Ktor Client: Picking Your Android HTTP Layer
By Priya Shah · Published · 5 min read

Every Android app eventually talks to a server, and the choice of HTTP client tends to outlive the feature that motivated it. Retrofit and Ktor Client are the two realistic options in a Kotlin codebase today, and the decision is less about raw speed than about how much machinery you want between your repository and the wire.
This comparison focuses on small-to-mid-sized projects: a handful of endpoints, one or two auth flows, JSON payloads, and a team that wants to ship without fighting its own stack. The numbers below are typical ranges from everyday projects, not benchmarks, and they should be read as orders of magnitude rather than precise measurements.
Setup Effort and Boilerplate
Retrofit asks for three pieces before your first call works: an interface with annotated methods, a JSON converter, and an OkHttp client underneath. In a fresh module that is usually 25 to 40 lines spread over two files, and the annotations make every endpoint readable at a glance. Most Android developers have written this code before, which shortens review time considerably.
Ktor Client is a single dependency with pluggable engines and content negotiation. A minimal setup is roughly 15 to 25 lines: install ContentNegotiation with kotlinx.serialization, add a default request block for the base URL, and you are calling endpoints. The catch is that you assemble behaviour yourself, so the first hour feels faster and the third week can feel slower if you skip structure.
Both stacks play well with Kotlin serialization and with Moshi or Gson on the Retrofit side. If your project already has a JSON library, matching it matters more than the client choice: mixing two serialization stacks in one app adds confusion that no HTTP library will pay back.
- Retrofit: interface-based, annotation-driven, familiar to most Android teams
- Ktor Client: plugin-based, configured in code, no annotation processing
- Both support kotlinx.serialization, Moshi and Gson converters
- Ktor needs an explicit engine choice; OkHttp and CIO are common on Android
Coroutines and Suspend Support
Retrofit has supported suspend functions since version 2.6, so a repository method can simply return the parsed body and let exceptions propagate. Cancellation works because the underlying call is cancelled when the coroutine scope dies. For most CRUD screens this is exactly the ergonomics you want, and there is nothing extra to configure.
Ktor Client was built around coroutines and exposes suspend calls as the default, including streaming responses through ByteReadChannel. That matters if you download files, consume server-sent events, or need to process a large payload incrementally. Ktor's HttpClient is also safe to share as a singleton, which keeps connection pooling consistent across features.
Neither library forces you onto a particular dispatcher. The practical difference shows up in error handling: Retrofit throws HttpException for non-2xx responses by default, while Ktor returns the response and leaves status checking to you unless you install the expectSuccess flag or the response validation plugin.
- Retrofit suspend support is stable and widely documented
- Ktor exposes streaming and cancellation more directly
- Ktor's expectSuccess decides whether 4xx/5xx throw or return
- Share one client instance per app, not per screen
Interceptors, Plugins and Cross-Cutting Concerns
Retrofit inherits OkHttp interceptors, and that ecosystem is deep. Auth token refresh, logging, retry with backoff, and request tagging are all solved problems with small, well-understood classes. An interceptor sees the raw request and response, which makes header injection and timing instrumentation straightforward, and it applies to every call without touching the API interface.
Ktor's equivalent is the plugin pipeline, and it is more granular. You can hook into request construction, response transformation, sending and receiving separately, which is useful for things like signing bodies or mapping error envelopes into sealed classes. The trade-off is that plugin ordering matters and debugging a misordered pipeline takes longer than reading a stack of interceptors.
For a small app with one auth flow, both approaches cost roughly the same effort. Once you have three or four cross-cutting concerns, Retrofit's interceptor chain is easier to reason about, while Ktor's typed plugins scale better when the concerns need to inspect or rewrite the body.
- OkHttp interceptors: request/response level, ordered, easy to test
- Ktor plugins: phase-specific hooks, typed configuration, order-sensitive
- Token refresh is a solved pattern in both; Ktor needs an authenticate block
- Logging is one line in each, but Ktor's Logging plugin needs level tuning
| Aspect | Retrofit | Ktor Client |
|---|---|---|
| Initial setup | 25-40 lines, interface plus converter | 15-25 lines, client plus plugins |
| Coroutine style | Suspend functions since 2.6 | Suspend by default, streaming built in |
| Cross-cutting logic | OkHttp interceptors | Plugin pipeline with phases |
| Testing support | Interface fakes, MockWebServer | MockEngine, pipeline-level tests |
| Release size impact | A few hundred KB with OkHttp | Similar range, engine-dependent |
| Best fit | REST APIs on Android | Multiplatform or streaming needs |
Binary Size and Build Impact
Retrofit plus OkHttp plus a converter typically adds a few hundred kilobytes to a release APK before shrinking, and R8 removes most of the unused surface. There is no annotation processor at runtime, so build times stay flat as the API surface grows. This is a well-trodden path and the tooling around it is mature.
Ktor Client on Android with the OkHttp engine pulls in similar core dependencies plus the Ktor core and plugin modules. Choosing the CIO engine avoids OkHttp but adds its own coroutine-based networking code. In practice the difference lands in the low hundreds of kilobytes either way, which rarely decides anything on a modern app.
Build impact is a more honest differentiator. Retrofit generates no code, so incremental builds are unaffected. Ktor's plugin configuration is compile-time Kotlin, which is also fast, but reflection-heavy setups with kotlinx.serialization can add a little to cold builds if you are not using the compiler plugin.
- Expect a few hundred KB either way in a shrunk release build
- R8 handles both well; keep rules are usually minimal
- No annotation processing in either library
- Ktor's engine choice changes the dependency footprint more than the client itself
Testing and Debugging Workflow
Retrofit interfaces are easy to fake: a hand-written implementation of the interface returns canned data without any network stack, which keeps unit tests fast. For integration-style tests, OkHttp's MockWebServer works out of the box and lets you assert on the exact request that left the client, including headers and query parameters.
Ktor ships a MockEngine that plugs in as the engine, so tests exercise the real plugin pipeline including serialization. That is a genuine advantage when your plugins do meaningful work, because a fake interface would bypass them entirely. The cost is that test setup requires constructing an HttpClient per test or sharing one carefully.
Debugging is close to a tie. Both give you readable logs, and both surface the cause chain when serialization fails. The friction appears when a converter or plugin swallows an error, so log the raw body at least once during development regardless of which client you choose.
- MockWebServer fits Retrofit's request-level assertions
- Ktor's MockEngine tests the full plugin pipeline
- Fake the repository interface for fast unit tests in both cases
- Always log raw bodies once when a serialization error is unclear
Where Each One Fits
Retrofit remains the lower-risk choice for a typical Android app: REST endpoints, JSON, token auth, and a team already fluent in it. The annotation style keeps API definitions close to the HTTP contract, and the OkHttp ecosystem covers almost any cross-cutting requirement without custom code.
Ktor Client earns its place when the same networking code must run on Android, iOS and the JVM backend, or when you need streaming, WebSockets, or fine-grained request pipeline control. For a small app with a single REST API, it is a reasonable choice but rarely a necessary one.
A pragmatic middle ground exists: keep Retrofit for the REST surface and add Ktor only for the specific feature that needs streaming or multiplatform support. Two clients in one app is a maintenance cost, so make that decision deliberately rather than by accident, and document it for the next person who opens the module.
- Retrofit: REST-first Android apps with an existing OkHttp setup
- Ktor: shared Kotlin code across platforms or streaming-heavy features
- Avoid mixing clients unless a concrete feature demands it
- Whichever you pick, wrap it behind a repository interface
- Retrofit wins on familiarity and interceptor ergonomics for REST-only Android apps.
- Ktor wins when networking code must be shared across platforms or stream data.
- Both add a similar amount to a shrunk release build; size rarely decides it.
- Wrap either client behind a repository so swapping later stays cheap.
Covers Kotlin, Jetpack libraries and Android architecture with a hands-on approach. Focuses on migration guides, database work and networking patterns for small teams.


