In this article I will explain with an example, how to convert JSON string to DataTable in ASP.Net using C# and VB.Net.
The JSON string will be first downloaded from an API using WebClient class and then will be converted to DataTable using JSON.Net library.
Download JSON.Net library
The JSON.Net library is available for download from the following URL.
ASPSnippets Test API
The following API will be used in this article.
The API returns the following JSON.
      "Name":"John Hammond",
      "Country":"United States"
      "Name":"Mudassar Khan",
      "Name":"Suzanne Mathews",
      "Name":"Robert Schidner",
You will need to import the following namespaces.
using System.Net;
using System.Data;
using Newtonsoft.Json;
Imports System.Net
Imports System.Data
Imports Newtonsoft.Json
Converting JSON string to DataTable
Inside the Page Load event handler, first the JSON string is downloaded from an API using DownloadString method of the WebClient class.
Finally, the JSON string is converted to DataTable using JSON.Net library.
protected void Page_Load(object sender, EventArgs e)
    if (!this.IsPostBack)
        ServicePointManager.Expect100Continue = true;
        ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
        string json = (new WebClient()).DownloadString("");
        Datatable dt = JsonConvert.DeserializeObject<DataTable>(json);
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    If Not Me.IsPostBack Then
        ServicePointManager.Expect100Continue = True
        ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType)
        Dim json As String = (New WebClient).DownloadString("")
        Dim dt As DataTable = JsonConvert.DeserializeObject(Of DataTable)(json)
    End If
End Sub
Convert JSON string to DataTable in ASP.Net using C# and VB.Net