Say you have to expose the same data to a mobile app, a React dashboard and three internal services. Which style do you build: REST, GraphQL or gRPC? All three move data between a client and a server, but they make very different trade-offs about who controls the shape of the response, how the bytes travel and what the browser can do for you.

This guide compares the three on the points that matter in practice: how each works, where it fits, where it hurts, and how to pick one. I have not included benchmark numbers, because the results depend on your payloads, your network and your database, and a figure copied from somewhere else would mislead you more than it would help.

REST: the web's default

REST (Representational State Transfer) is an architectural style described by Roy Fielding in his 2000 dissertation. In everyday use it means an HTTP API built around resources, usually with JSON bodies.

Core principles

  • Resources have URLs. /users/42 is a user, and /users/42/orders is the orders of that user.
  • HTTP verbs carry the intent. GET reads, POST creates, PUT replaces, PATCH changes part of a resource and DELETE removes it. GET, PUT and DELETE are idempotent, so repeating them gives the same result.
  • Stateless requests. Every request carries what the server needs, such as a token, so any server in a pool can answer it.
  • Status codes describe the outcome. 200, 201, 404 and 409 mean something to every HTTP client.
GET /users/42 HTTP/1.1
Accept: application/json

HTTP/1.1 200 OK
Content-Type: application/json

{"id":42,"name":"Ada","email":"ada@example.com","address":{"city":"London"},"createdAt":"2025-03-01"}

Where REST fits best

  • Standard CRUD applications and admin tools.
  • Public APIs, because everyone can call them with a browser, curl or any language.
  • Applications that benefit from HTTP caching, since GET responses can be cached by browsers, proxies and CDNs.
  • Webhooks and integrations with third parties.

Limitations: over-fetching and under-fetching

The server decides what an endpoint returns. If your screen needs the name only, /users/42 still sends the whole object, which is over-fetching. If the screen needs the user, the last orders and the items of each order, you may call /users/42, /users/42/orders and then /orders/9/items once per order, which is under-fetching, and it costs round trips. Teams work around both with extra endpoints, query parameters such as ?fields=name or ?include=orders, or a backend-for-frontend layer, but each workaround adds API surface to maintain.

Tip: many APIs called REST are really HTTP APIs with JSON. That is fine. What matters is that you use verbs and status codes consistently and document the contract, for example with OpenAPI.

GraphQL: the client chooses the shape

GraphQL is a query language and runtime that Facebook created and open-sourced in 2015. The specification is now maintained by the GraphQL Foundation. Instead of many endpoints, the server exposes one, usually /graphql, and the client asks for exactly the fields it needs.

Core principles

  • A typed schema describes every type, query, mutation and subscription. It is the contract.
  • Declarative queries. The client lists the fields, including nested ones, and gets back a response with the same shape.
  • Resolvers are server functions that load the data for each field. This is where you call databases and other services.
  • One endpoint, usually a POST with a JSON body that contains the query and its variables.
query {
  user(id: 42) {
    name
    orders(last: 2) {
      id
      total
    }
  }
}
{
  "data": {
    "user": {
      "name": "Ada",
      "orders": [
        { "id": "9", "total": 31.5 },
        { "id": "10", "total": 12 }
      ]
    }
  }
}

One request returned the user and the orders, and nothing else. The REST version needed at least two calls and sent more fields than the screen used.

Where GraphQL fits best

  • Complex single-page applications, for example with React or Next.js, where one screen needs several nested resources.
  • Dashboards and mobile apps with different data needs on the same backend.
  • A gateway that gives frontend teams one flexible API on top of many services.

Limitations

  • HTTP caching is harder. Queries usually travel as POST requests to a single URL, which browsers and CDNs do not cache by default. You need client-side caches, persisted queries or GET-based queries to get caching back.
  • Errors look different. A response can have HTTP status 200 and still contain an errors array, so monitoring that only watches status codes misses failures.
  • Query cost and authorization. A client can ask for deeply nested data. You need depth and complexity limits, and you must check permissions in every resolver, not only at the entry point.
  • The N+1 problem. A naive resolver for each order may query the database once per order. Batching tools such as DataLoader exist for this reason.
  • More setup than a few REST routes: schema, resolvers, tooling and a security model.

gRPC: built for service-to-service calls

gRPC is a remote procedure call framework that Google open-sourced in 2015. You define services and messages in a .proto file, and the tooling generates typed clients and servers in many languages. Calls travel over HTTP/2, and the messages are encoded with Protocol Buffers.

Core principles

  • HTTP/2 transport. Many calls share one connection (multiplexing), headers are compressed and the framing is binary.
  • Protocol Buffers. A compact binary format with a schema. Fields are identified by numbers, not by names.
  • Four call types: unary (one request, one response), server streaming, client streaming and bidirectional streaming.
  • Built-in features: deadlines, metadata, status codes and generated code.
syntax = "proto3";

service UserService {
  rpc GetUser (GetUserRequest) returns (User);
  rpc WatchOrders (WatchRequest) returns (stream Order);
}

message GetUserRequest { int32 id = 1; }

message User {
  int32 id = 1;
  string name = 2;
  string email = 3;
}

How small is the payload? A worked example

Take a message with id = 150 and name = "Ada". Protocol Buffers write the id as the tag 08 followed by the varint 96 01, and the name as the tag 12, the length 03 and the three letters 41 64 61. That is 8 bytes:

08 96 01 12 03 41 64 61

The same data as compact JSON, {"id":150,"name":"Ada"}, is 23 bytes, because it repeats the field names in every message. I counted both by hand from the encoding rules. The gap shrinks with long strings and grows with many small fields, and compression such as gzip narrows it further for JSON. Treat it as an illustration of why binary formats are compact, not as a promise of a speed-up.

Where gRPC fits best

  • Communication between microservices inside your own network.
  • Low-latency backends for mobile apps, where small payloads and one long-lived connection help.
  • Streaming: live updates, telemetry and long-running operations.
  • Polyglot systems that want one generated, typed contract.

Limitations

  • Browsers cannot call gRPC directly, because web pages do not get the low-level control over HTTP/2 that it needs. You use gRPC-Web with a proxy such as Envoy, or a browser-friendly protocol such as Connect.
  • The payloads are not readable. You need the schema and a tool such as grpcurl to look at a call.
  • No built-in HTTP caching in the way GET requests have it.
  • Less friendly to the public. Third parties have to generate clients from your .proto files.

Side-by-side comparison

Transport. REST normally runs over HTTP/1.1 or HTTP/2 and is not tied to either. GraphQL usually runs over HTTP, most often as POST requests to one endpoint. gRPC requires HTTP/2.

Data format. REST and GraphQL use JSON, which is text and readable. gRPC uses Protocol Buffers, which is binary and compact.

Over-fetching and under-fetching. REST has a high risk of both, unless you add field selection or extra endpoints. GraphQL has a low risk, because the client lists the fields. gRPC returns a fixed message per method, so you design the messages for the callers, and field masks can narrow responses.

Caching. REST works with the whole HTTP caching system: Cache-Control, ETag and conditional requests. GraphQL needs client-side caches, persisted queries or GET queries. gRPC has no built-in HTTP cache, so you cache in the application or a service layer.

Browser support. REST and GraphQL work natively in every browser. gRPC needs gRPC-Web or a similar bridge.

Streaming. REST can use server-sent events or WebSockets as add-ons. GraphQL has subscriptions, usually over WebSockets. gRPC has native streaming in both directions.

Contract and typing. REST has an optional contract, usually OpenAPI. GraphQL has a mandatory schema. gRPC has a mandatory .proto file with generated code.

Learning curve. REST is the lowest. GraphQL is medium, because of schemas, resolvers and caching. gRPC is medium to high, because of Protocol Buffers, code generation and the browser story.

Performance in plain words

gRPC is often faster for service-to-service traffic, for three reasons: smaller messages, cheaper encoding and decoding, and many calls over one connection. But in many applications the database or a downstream call takes far longer than the serialization, so a faster wire format changes little. REST over HTTP/2 also multiplexes requests, and a gzip-compressed JSON response is much smaller than the plain one. Measure your own workload before you choose a protocol for speed.

Debugging payloads in your daily workflow

With REST and GraphQL, most integration bugs live in the JSON. A GraphQL request is itself a JSON envelope, for example {"query":"...","variables":{}}, and a missing quote or brace in that envelope fails before GraphQL sees the query. Paste a suspicious request or response into the JSON Validator to find the exact position of the problem, and use the JSON Formatter to read deeply nested data. If the parser reports an Unexpected token error, the guide to JSON parse errors explains the usual causes.

Authentication adds encoded data to the picture:

  • A Basic authorization header, such as Authorization: Basic dXNlcjpwYXNz, is Base64 text for user:pass. The Base64 Encoder / Decoder shows what a header really contains. That is also a reminder that Base64 is not encryption.
  • gRPC metadata keys that end in -bin carry binary values, which are Base64-encoded on the wire. Decode them with the same tool when you inspect a call.
  • A bearer token is usually a JWT, which uses the Base64URL variant. Use the JWT Decoder to read its claims, for example when a token has expired.

All three tools run in your browser, but avoid pasting production credentials or tokens into any online tool.

For gRPC itself, use tools made for it, such as grpcurl or a gRPC client in your API tool. If your browser app calls a REST or GraphQL API on another origin and fails before any JSON arrives, the cause may be CORS. Our CORS guide covers the fixes for the common servers.

How to choose

Work through these questions in order:

  1. Who calls your API? If it is the public, third parties or any browser or script, start with REST. If it is only your own services, gRPC is a strong candidate.
  2. Is it a browser or mobile client with many different screens and nested data? If yes, and you can afford the setup, look at GraphQL, often as a gateway.
  3. Do you need streaming or very low latency between services? If yes, choose gRPC for those paths.
  4. Does HTTP caching matter a lot? Prefer REST for read-heavy, cacheable data.
  5. How big is the team and how much tooling can it carry? A small team with a simple domain gets the most from REST. GraphQL and gRPC pay off when many teams share contracts.

A short summary of the answers:

  • Small to medium CRUD product, public API: REST.
  • Rich frontend with many nested resources: GraphQL, or REST with a backend-for-frontend.
  • Internal microservices, streaming, polyglot teams: gRPC.
  • Large system: a mix, as described below.

Best practices for all three: version your contract, document it, validate input on the server, limit payload sizes, set timeouts, return useful errors and log request IDs.

FAQs

Can REST, GraphQL and gRPC coexist in the same application architecture?

Yes, and in larger systems they often do. A common layout is gRPC between internal services, a GraphQL layer that gives the frontend one flexible API on top of those services, and REST for public endpoints and webhooks. Each style is used where its strengths matter. The cost is that you maintain several contracts, so only add a style when it solves a problem you actually have.

Why is gRPC faster than REST APIs?

It usually is not one thing but a combination. Protocol Buffers messages are smaller and cheaper to encode and decode than JSON text. HTTP/2 sends many calls over one connection and compresses headers. Generated code avoids a lot of runtime work. How much of that you notice depends on your payload size and on how long your database and other services take, so measure it for your workload.

Does GraphQL completely replace REST APIs?

No. GraphQL solves the problem of clients that need flexible, nested data, and it does that well. It gives up easy HTTP caching and simplicity, and many teams run GraphQL in front of existing REST or gRPC services. Public APIs, webhooks, file downloads and simple CRUD services are still very comfortable in REST.