AutoMapperLite

A lightweight, customizable object-to-object mapping library for .NET. Simplify DTO and entity mapping with fluent profiles, nested-property support, and flexible configuration — without the overhead of a full AutoMapper installation.

v4.4.1 — current release MIT licensed net6.0 – net10.0 Thread-safe

Created and maintained by Atik Hassan. Versions prior to 4.4.1 are deprecated — see the changelog.

Features

Zero-config auto-mapping

Auto-maps same-named, same-type properties with no configuration.

Nested mapping

Map nested objects and nested List<T> properties whose item types have a registered map.

Fluent profiles

ForMember and ForPath for custom and deeply-nested member mapping, similar to AutoMapper.

Collections

Map to List<T>, arrays, or common collection interfaces (IList<T>, ICollection<T>, IReadOnlyList<T>, IEnumerable<T>), item by item.

DI-friendly

AddAutoMapperLite(Assembly) registers IMapperConfig and IMapper as singletons.

Thread-safe

Configuration and mapping can both be used concurrently.

Installation

Install the NuGet package in your project:

dotnet add package AutoMapperLite --version 4.4.1

Targets net6.0, net7.0, net8.0, net9.0, and net10.0.

Quick Start

1. Register AutoMapperLite in your DI container

using System.Reflection;

var builder = WebApplication.CreateBuilder(args);

// Register all profiles from the executing assembly
builder.Services.AddAutoMapperLite(Assembly.GetExecutingAssembly());

var app = builder.Build();

2. Create a mapping profile

Define your mappings by creating a class that inherits from Profile and overrides Configure:

using AutoMapperLite;
using AutoMapperLite.Interfaces;

public class MyMappingProfile : Profile
{
    public override void Configure(IMapperConfig config)
    {
        // Basic map: same-named, same-type properties auto-map for free.
        config.CreateMap<Country, CountryViewModel>();

        // ForMember/ForPath functions must return the ALREADY-MAPPED value,
        // not the raw source sub-object — the library never implicitly
        // converts types inside a custom mapping function. When source and
        // destination property types differ, map through the mapper itself.
        var mapper = new Mapper(config);

        config.CreateMap<Organization, OrganizationViewModel>()
            .ForMember(dest => dest.CountryViewModel,
                       src => mapper.Map<CountryViewModel>(src.Country));

        config.CreateMap<Location, LocationViewModel>()
            .ForPath(dest => dest.OrganizationViewModel.CountryViewModel,
                      src => mapper.Map<CountryViewModel>(src.Organization.Country));
    }
}
Verified: every code sample on this site is checked against the actual library before publishing — see Examples → Nested object mapping for the same pattern with its assertions.

3. Inject and use the mapper

public class MyService
{
    private readonly IMapper _mapper;

    public MyService(IMapper mapper)
    {
        _mapper = mapper;
    }

    public LocationViewModel GetLocationViewModel(Location location)
    {
        return _mapper.Map<LocationViewModel>(location);
    }
}

Quick answers

Is AutoMapperLite free and open source?
Yes. AutoMapperLite is free for personal and commercial use, licensed under the MIT License.
Is AutoMapperLite thread-safe?
Yes. Both mapping configuration (CreateMap) and mapping itself (Map) are safe to use concurrently.
How does AutoMapperLite compare to AutoMapper or Mapster?
AutoMapperLite trades some flexibility (no LINQ projection, no convention/coercion engine) for a much smaller footprint. Like AutoMapper and Mapster, it compiles each configured type pair into a cached delegate rather than mapping via raw reflection — it now beats AutoMapper on warm, repeated calls for both object and collection mapping, though Mapster remains faster on raw per-call time. See the full comparison and performance pages.

See the full FAQ →

Where next

Getting Started

Install the package and register it with dependency injection in a few lines.

Guide

Mapping, configuration, collections, nested objects, and dependency injection in depth.

API Reference

Full signatures for IMapper, IMapperConfig, MapBuilder<TSource,TDestination>, Profile, and the DI extension method.

Examples

Runnable examples: basic mapping, custom members, deep nested paths, collections, and nested collection properties.

Performance

Real, measured benchmark numbers for the mapping hot path.

Contributing

How to build, test, and submit changes.