Adding an “Export to Excel” Option in Fiddler

Fiddler (HTTP proxy for Windows) is a valuable tool for finding out what is happening in an external environment (e.g. when a client uses IE).

It’s sometimes helpful to pull it’s data into Excel – this allows you to highlight dramatic deviations.

The scripting API allows you to do this – drop the following code into the Fiddler script file-

public static ToolsAction("Copy Request Timings to Excel")
function DoHighlightSlowRequests() {
  var oSessions = FiddlerApplication.UI.GetAllSessions();
     
  var s: String = "";
  s = s +
    "Index\t" +
    "URL\t" +
    "Is HTTPS\t" +
    "Response Code\t" +
    "Request Bytes\t" +
    "Response Bytes\t" +
         
    "ClientConnected\t" +
    "ClientBeginRequest\t" +
    "ClientDoneRequest\t" +
         
    "ServerConnected\t" +
    "FiddlerBeginRequest\t" +
    "ServerGotRequest\t" +   
    "ServerBeginResponse\t" +
    "ServerDoneResponse\t" +
    "ClientBeginResponse\t" +
    "ClientDoneResponse\t" +
         
    "DNSTime\t" +
    "GatewayDeterminationTime\t" +
    "TCPConnectTime\t" +
    "HTTPSHandshakeTime\t" +
         
    "Request Transmission Time\t" +
    "Server Time Spent\t" +
    "Response Transmission Time\t" +
    "Transmission time (down + up)\t" +
    "Total Round Trip Time" +
    "\r\n";
  for (var x:int = 0; x < oSessions.Length; x++){
    var session = oSessions[x]
    var timer = session.Timers
    // use tabs intead of CSV because
    // Excel and .NET have incompatible 
    // expectations for unicode format
         
    var t = oSessions[x].Timers
    var transmissionTime = 
      new TimeSpan(t.ServerGotRequest.Ticks - 
                   t.FiddlerBeginRequest.Ticks).Milliseconds
    var serverTimeSpent = 
      new TimeSpan(t.ServerDoneResponse.Ticks - 
                   t.ServerGotRequest.Ticks).Milliseconds 
    var responseTransmissionTime = 
      new TimeSpan(t.ServerDoneResponse.Ticks - 
                   t.ServerBeginResponse.Ticks).Milliseconds 
    var totalTransferTime = 
      transmissionTime + responseTransmissionTime
    var roundTripTime = 
      new TimeSpan(t.ClientDoneResponse.Ticks - 
                   t.ClientBeginRequest.Ticks).Milliseconds 
         
    var transmissionTimeStr = 
      transmissionTime < 0 ? "" : transmissionTime + ""
    var serverTimeSpentStr =  
      serverTimeSpent < 0 ? "" : serverTimeSpent + ""
    var responseTransmissionTimeStr = 
      responseTransmissionTime < 0 ? "" : responseTransmissionTime + ""
    var totalTransferTimeStr = 
      totalTransferTime < 0 ? "" : totalTransferTime + ""
    var roundTripTimeStr =
      roundTripTime < 0 ? "" : roundTripTime + ""
            
    s = s +
        x + "\t" +
        oSessions[x].url + "\t" +
        oSessions[x].isHTTPS + "\t" +
        oSessions[x].responseCode + "\t" +
        oSessions[x].requestBodyBytes.Length + "\t" +
        oSessions[x].responseBodyBytes.Length + "\t" +               
             
        oSessions[x].Timers.ClientConnected.Ticks + "\t" +
        oSessions[x].Timers.ClientBeginRequest.Ticks + "\t" +
        oSessions[x].Timers.ClientDoneRequest.Ticks + "\t" +
             
        oSessions[x].Timers.ServerConnected.Ticks + "\t" +
        oSessions[x].Timers.FiddlerBeginRequest.Ticks + "\t" +
        oSessions[x].Timers.ServerGotRequest.Ticks + "\t" +
        oSessions[x].Timers.ServerBeginResponse.Ticks + "\t" +
        oSessions[x].Timers.ServerDoneResponse.Ticks + "\t" +
        oSessions[x].Timers.ClientBeginResponse.Ticks + "\t" +
        oSessions[x].Timers.ClientDoneResponse.Ticks + "\t" +
            
        oSessions[x].Timers.DNSTime + "\t" +
        oSessions[x].Timers.GatewayDeterminationTime + "\t" +
        oSessions[x].Timers.TCPConnectTime + "\t" +              
        oSessions[x].Timers.HTTPSHandshakeTime + "\t" +
             
        transmissionTimeStr + "\t" + 
        serverTimeSpentStr + "\t" + 
        responseTransmissionTimeStr + "\t" + 
        totalTransferTimeStr + "\t" + 
        roundTripTimeStr +
        "\r\n";
  }
  System.Windows.Forms.Clipboard.SetText(
    s.ToString(), 
    TextDataFormat.Text);     
}

9 Replies to “Adding an “Export to Excel” Option in Fiddler”

  1. Hi,

    I have copied the code into Rules -> Customize Rules and then placed under fiddlerscript using the editor application. I don’t the option in fiddler. Could you please help If I am doing it right?

  2. I see the option show up within TOOLS, it appears under “Reset Script”.
    It is important to copy the above code to the right file (Using Fiddler Script Editor).
    You can use “Reset Script” as reference (as it too is defined within the script.

    1. Hi can you please help .
      I have seen the option under Tools ‘copy timings to excel’ and I am not sure where the excel is being to save (It just blows out)
      Thanks.

  3. Hi,
    I have dropped this code in Fiddler =Script and Save Script.
    But I do not see any option to Export into Excel.
    Please Advice.

    Thanks& Best regards,

  4. For me –
    Rules -> Customize Rules
    Find “Reset Script” section and paste directly underneath
    Select rows you want, run Tools > Copy Request Timings to Excel
    Data is placed in clipboard

Leave a Reply to Naresh Cancel reply

Your email address will not be published. Required fields are marked *