Skip to content
IT glossary
BackendUpdated December 3, 2026

DTO

A data transfer object carries a defined set of fields across a boundary, such as from a server to a client, without exposing the application’s entire internal model.

Also known as: Data Transfer Object

What is a DTO?

Suppose an order endpoint needs to show a customer the order number and total. The application may also track payment references, fulfillment details, and internal notes. An OrderSummary DTO (Data Transfer Object) gives the caller just the fields needed for that response. Its shape comes from what the recipient needs, not from how the application stores the order.

How DTOs fit into a request

An endpoint can have one DTO for input and another for output. For example, a create-order request might carry product IDs and quantities, while the response contains an order ID and a total calculated by the server. Using different types lets you be explicit about which values the client supplies and which values the server owns.

On the way in, a framework can deserialize the request body into an input DTO and check field types and required values. The application then applies business rules, such as whether the items can be ordered. On the way out, the application maps the result to an output DTO and serializes it. The DTO is the structure in code; JSON is one possible representation sent over the network.

Example in C#

public sealed record OrderSummary(string OrderNumber, decimal Total);

static OrderSummary ToSummary(Order order) =>
    new(order.Number, order.Total);

The mapping makes the response fields easy to see in a code review. Adding an internal note to Order does not automatically add it to OrderSummary. The DTO can also flatten data: a response might include a customer name without including the entire customer object.

Where DTOs help, and where they add work

DTOs are common in HTTP APIs and messages between services. They can also carry data between application layers when those layers need different shapes. An ORM entity is shaped by persistence, and a domain model represents business concepts and rules. A DTO serves the transfer contract, so it usually holds data and leaves business decisions elsewhere. Checking that a quantity is a positive integer is different from deciding whether the customer can buy that quantity.

Separate DTOs let internal models change without necessarily changing what callers receive. They do not make every API change safe: renaming a field in the serialized response can still break clients. They also introduce mapping code to maintain, so a separate type for every private method call is rarely useful when both sides already need the same shape and change together.

How it comes up in interviews

You may be asked why a controller should not return an ORM entity directly. Give a concrete example of a field you would leave out, then explain how a response DTO keeps the public contract from depending on the storage model. A good follow-up is to describe the trade-off: you gain control over what crosses the boundary, but you have to maintain and test the mapping.