Dynamic Object (ExpandoObject) Builder
Build a C# dynamic ExpandoObject from sample JSON or key-value pairs free online. Generates ready-to-paste code for ASP.NET projects that need flexible objects.
How to Use This Tool
When You Don't Know the Shape of Your Data Until Runtime
Most of the time in C#, you know your data's structure ahead of time and define a class for it. Sometimes you genuinely don't — building a response object that varies by request, working with truly dynamic configuration, or prototyping before the final shape is locked down. ExpandoObject exists for exactly this situation, letting you build an object property by property at runtime.
Writing the ExpandoObject assignment code by hand for anything beyond a couple of fields gets repetitive fast. This tool takes sample JSON representing the shape you want and generates the actual C# code: the ExpandoObject declaration followed by every property assignment needed to match your sample.
Dot Notation Without Giving Up Flexibility
The appeal of ExpandoObject over a plain Dictionary is syntax. Once cast to dynamic, obj.name reads naturally in code, closer to how you would access a real class property, while still allowing properties to be added or changed at runtime without a fixed class definition constraining you.
Nested Structures Generate Nested Objects
When your sample JSON has a nested object, like an address field containing city and zip, the generated code creates a separate ExpandoObject for that nested structure and assigns it to the parent property, mirroring exactly how the source data was organized rather than flattening everything into one level.
Frequently Asked Questions
No comments yet
Be the first to share your experience with this tool!