Convert XML File to Classes

I see so many questions, articles, and tools on how to convert XML file to classes in C# or VB.NET and I am disappointed people are missing something extremely simple. If you are using any of the most recent versions of Visual Studio, this functionality is built-in. Yes, you heard me. No need to install tools or use serializers and deserializers.

Follow these few steps:

  1. Things are simple. Copy a valid XML into the clipboard.
  2. Create a blank class file in your project.
  3. In the menu, go to EDIT / Paste Special / Paste XML As Classes.
Convert Xml File To Classes in Visual Studio

Convert Xml File To Classes in Visual Studio

Voila!

If you went and tried it, you may have also noticed you can convert JSON into classes too.

Share the (old) news and stop listening to people that make your life difficult.