CloneBox CloneBox CloneBox Deep-clone any .NET object graph

Deep-clone any .NET object — or copy into another. Super easy, very fast, and it just works across the graphs you actually use. Free and open source from the makers of ETLBox.

Get Started

NuGet version MIT license .NET targets

Why another cloner?

Flat POCOs are easy. Real graphs are not.

Cycles blow the stack. ExpandoObject comes back sharing nested instances. Dictionaries lose their key types. Mappers and JSON round-trips were never cloners — they just look like one until you check the result.

CloneBox is built for the hard cases, with an API that stays tiny: CloneX() for a deep copy, CloneXTo() for copying into a target.

using CloneBox;

var customer = new Customer {
    Id = 1,
    Name = "Ada",
    Address = new Address { City = "Berlin" }
};

var copy = customer.CloneX();
// copy is a new Customer; Address is a new instance too

Or clone into another object

CloneXTo() copies matching members onto a different type or onto an instance you already have. Extra fields on the target stay unchanged.

var source = new Customer {
    Id = 1,
    Name = "Ada",
    Address = new Address { City = "Berlin" }
};

var dto = new CustomerDto { ExtraOnTarget = "keep-me" };

source.CloneXTo(dto);
// dto.Id / Name / Address filled; ExtraOnTarget still "keep-me"

Install from NuGet and you are done — no license key, no trial, no setup beyond the package reference.

Real deep clones

CloneX() copies nested objects, collections, arrays, and dictionaries — including cycles — without shared identity.

Clone into existing objects

CloneXTo() fills a different type or an instance you already have. Extra target fields stay put.

Dynamics included

ExpandoObject and mixed graphs work the same way as typed POCOs — including clone-into a DTO.

Very fast

Built for hot paths. Competitive with specialized cloners on simple graphs — and still correct when the graph gets hard.

Benchmarks at a glance

Release / net10.0. A time is only listed when the result was correct — — means wrong output or a crash.

Librarysimplecyclicdynamicintopass
CloneBox0.35 µs0.33 ms1.92 µs0.91 µs4/4
DeepCloner0.20 µs0.37 ms1.18 µs—3/4
FastDeepCloner2.76 µs———1/4
CloneExtensions0.17 µs———1/4
AnyClone3.40 µs———1/4
Mapster / AutoMapper~0.2 µs———1/4
Newtonsoft.Json2.31 µs———1/4

Full benchmark notes

How CloneBox compares

Same libraries as above. Correctness first — speed only counts when the copy is right.

LibrarycyclicdynamicintoTests & maintenance
CloneBoxYesYesYes280+ tests, actively maintained by ETLBoxperts
DeepClonerYesYesLimitedMature, slower cadence
FastDeepClonerCrash——Thin coverage, often unmaintained
CloneExtensions—Wrong key types—Thin coverage, often unmaintained
AnyClone—Shared nested refs—Thin coverage, often unmaintained
Mapster / AutoMapperShared refsFail / wrongNew instanceMappers — not cloners
Newtonsoft.JsonShape / key lossWrongNew instanceSerializer round-trip

Need more control?

Defaults cover most cases. When they don’t, CloneSettings lets you skip members, limit visibility, opt into ICloneable, or plug in logging.

var clone = source.CloneX(new CloneSettings {
    DoNotCloneProperty = p => p.Name == "Password",
    IncludeNonPublicFields = false,
    Logger = logger
});

Settings · Skip members

Add CloneBox to your project

MIT licensed, no trial key — from the makers of ETLBox.

1.
Install the package

dotnet add package CloneBox — netstandard2.0, net47, net48, and net10.0.

Open on NuGet
2.
Clone your first object

Use CloneX() for a deep copy, or CloneXTo() to fill an existing instance.

Getting started
3.
Dig into the guide

Clone-into details, settings, skip rules, and benchmarks — when you need to go deeper.

Browse the guide