Skip to content
Martin Zahálka edited this page Feb 18, 2026 · 3 revisions

ZMapper

High-Performance Object Mapping for .NET

AutoMapper's fluent API + Mapperly's compile-time source generation = ZMapper


ZMapper is a high-performance .NET object mapping library that combines the best of both worlds:

  • AutoMapper's familiar fluent configuration API (CreateMap, ForMember, MapFrom)
  • Mapperly's compile-time source generation for near-zero runtime overhead

All mapping code is generated at build time by a Roslyn source generator, resulting in ~17 ns per object mapping — on par with hand-written mapping code and 3x faster than AutoMapper.

Key Highlights

Feature Description
Performance ~17 ns per mapping, 3x faster than AutoMapper
Compile-Time Safety No runtime reflection, all code generated at build time
Familiar API AutoMapper-style fluent configuration
Zero Config Single NuGet package, no separate analyzer needed
Modern .NET Supports .NET 10 and netstandard2.0 (.NET Framework 4.6.1+)

Quick Example

using ZMapper;

// 1. Define a mapping profile
public partial class UserProfile : IMapperProfile
{
    public void Configure(MapperConfiguration config)
    {
        config.CreateMap<UserDto, User>()
            .ForMember(dest => dest.FullName,
                       opt => opt.MapFrom(src => $"{src.FirstName} {src.LastName}"))
            .ForMember(dest => dest.ContactEmail,
                       opt => opt.MapFrom(src => src.Email));
    }
}

// 2. Use the mapper
IMapper mapper = Mapper.Create();
var user = mapper.Map<UserDto, User>(dto);

// Or use the auto-generated extension method
var user = dto.ToUser();

Wiki Contents

Project Info

Version 1.2.1
License MIT
Author Martin Zahalka
Repository github.com/zcloudcz/ZMapper
NuGet dotnet add package ZMapper
Frameworks net10.0, netstandard2.0

Clone this wiki locally