Fiddler Extension – Request to Code

This Fiddler extension generates C#, VB, or Python code to duplicate a web request.  You simply drag one or more Fiddler sessions into the “Code” tab or use the ‘r2c <partialURL1> <partialURL2> …’ QuickExec command and the extension will produce appropriate code that you can copy and paste into your program that reproduces those requests. You can also run the code directly from the extension tab.

Download: Fiddler Extension - Request To Code (version, 75.73 kB zipped)

This can be useful for a number of purposes:

  • Submit form data programmatically – fill out a form online once with Fiddler running, then use the extension to copy and paste the request code into your own program.  You could then make this request as many times and as often as you need to.
  • Easily codify web requests – request resources like RSS feeds, images, XML, etc… from your program.  Further modify the web requests to your needs.
  • Programmatically test differing header values – you can easily modify the request functions so that you can try varying values for various HTTP headers.  This way you can test your web site or web service against these various headers.
  • Run code directly from the Code tab – you can use the “Run Code” button to run the code currently in the Code tab.
  • Automatically generate code in conjunction with FiddlerCore – Reference both FiddlerCore and FiddlerCoreRequestToCode in your project and you can generate code and do whatever you want to do with it. For instance, you could write a file for each session you observe that contains the Request To Code code in it. See an example and learn more…

To Install:

  1. Copy FiddlerRequestToCode.dll from the .zip file into your Fiddler2\Scripts folder.
  2. You’ll need to restart Fiddler if it’s already running.

Read the Changelog.


  1. This is a really nice plugin, but I’d like the code to be more extensible, ex: use partial method to being able to extend generated code ex to parse each request before issuing and each request.

    In pratical situation where I’m using generated code, I’m forced to modify generated code to modify stuff to inspect response from a specific request and extracting data to use in subsequent request (as I do with webperformanceTEst in VS).

    Gian Maria.

  2. Thanks a lot for writing this, it came in really useful! The C# could do without ugly method names, exception handling, and out parameters. Also it doesn’t seem to respect the order of the attributes, it would be nice if it mirrored the raw request exactly. Why not make a version which generates one fire-and-forget request using TCP sockets? Very best regards

  3. Hi and thanks for this extension
    can you upgrade this extension to generate php code to duplicate a web request?
    I’m not developer and cant upgrade this but i need for it
    please upgrade it
    thank you

    • Hi Hadi. Thanks for the suggestion to add PHP. I think that’s reasonable. I’ll add it to the feature list, though it will take some time to get it released. Thanks, ~Chad

  4. Thanks for writing this.

    It would be really useful if this extension parsed application/x-www-form-urlencoded POST bodies and generated a dictionary instead of injecting the body as a string.

    I’d contribute the change myself if this was open source.

    • Hi and thanks for the suggestion. I’ll take a look into making the change and thanks for offering to do take care of it yourself, if the source was open. Thanks, ~Chad

  5. I’ve been using Fiddler with this Request-to-Code extension for several years now–such an incredible time-saver. Thank you SO very much!

  6. Pingback: Techdays 2015 – Jour 2 – Nos impressions | OCTO talks !

  7. How can i get import/reference Newtonsoft.Json (C#) ?
    I am trying to run JObject.parse(response) and i get the following error message, please help!

    Error: Could not compile source code
    The name JObject does not exist in the current context
    Predefined type ‘Microsoft.CSharp.RuntimeBinder.Binder’ is not defined or imported
    One or more types required to compile a dynamic expression cannot be found.
    Are you missing a reference?

    • Hi. Click the arrow on the “Run Code” button and choose “Preferences”. In there, on the left you can add a reference to your DLL and then on the right add your “using” statement (minus the using). Let me know if you have any issues. Thanks, ~Chad

  8. First of all great work on this tool…
    Second I’m not being able to port the code to Windows Phone 8.1 Universal App
    As it uses Windows.Web.Http reference
    Any ideas?

    • Hi Pedro, thanks for your feedback. I don’t have any immediate suggestions. I’ll need to take a look and see if there’s any way to modify the code so it will work for your Windows Phone App. Let me know if you have any working samples and I can try to incorporate them. Thanks, ~Chad

  9. Hi Chad,

    Many thanks for providing this excellent plugin! Was bashing my head against the wall trying to reproduce a sophisticated POST request. Then stumbled on your amazing job and I’m saved! Thank you.

  10. You have saved a lot of time for me. Worked like a charm. Would love to donate for your effort. Cheers, Ravee

  11. This is a really handy extension. Too bad I discovered it AFTER writing a series of requests in C# first! I’ll be sure to use this often in the future. Thank you very much for putting it together.

  12. Any chance of adding in Javascript/jQuery? Seems Microsoft is pushing us all there at the moment.

    • Hi Trev. Thanks for the suggestion. I assume – so correct me if I’m not following – but you mean you’d like to see JS (possibly using jQuery) that would make an equivalent AJAX call?

  13. I am interested in capturing the tunnel requests ? How can I do that ???

    • What are you hoping to accomplish by getting code for the CONNECT tunnels?

      By design, the extension does not generate code to duplicate the CONNECT tunnels. This is because all of the generated code automatically will tunnel/CONNECT as needed. For instance, the HttpWebRequest that’s used in the .NET languages automatically does a CONNECT when you use it to go to a HTTPS URL. Thanks, ~Chad

  14. Fantastic work! Your extension has been a huge time-saver for me. Thanks!!! About the only thing I find I must modify to make a lot of the generated scripts (C#) work is defining a global CookieContainer variable and assigning it to the CookieContainer of every request so that all cookies are martialled correctly.

    • Hi Ryan. You’re not alone! Others have also asked for cookie handling. I plan to add something and what you’re doing sounds about right. Thanks! ~Chad

  15. Chad,
    Your product rocks and has helped solve several issues.
    Thank You very much for your time and effort.
    I have a suggestion, would it be possible for you to allow the generation of code compatible to drop into linqpad. I can do that now, by stripping off the parts that are not needed, but it would be nice to have a cut and paste option. Just being lazy :-)

    – Bob

  16. Hello Chad! I just wanted to take the time to say thank you for this awesome extension! Being somewhat new to coding, I was beginning to become very frustrated with HTTP related development. Whether it involved the headers, postData or cookies, I always seemed to get bad responses. Thanks to your extension, however, I have had something to reference within my programming language, and it has enabled me to build a steady understanding of it all. So again, thank you for taking the time write this nifty plugin, and I give you a nod for releasing it for free. Thanks again!

    • Thanks so much for the kind words. I’m happy to hear it has helped you get a better grasp on HTTP! I know I gained a lot of understanding developing the extension and handling a lot of the corner cases. HTTP is very important to understand, regardless of whatever other languages you develop with. Cheers! ~Chad

  17. Hi , Chad . Its amazing :)


  18. Hi Chad,
    This is very cool indeed!
    1 small bug: method names are truncated Generatecode becomes …._nerateForm, ….._receive becomes …._eceive , ….._downloadzip becomes …..oadzip.
    1 suggestion: is it possible to handle cookies better? Maybe check if cookes are returned, add them to a collection and send the dynamic values on subsequent requests, instead of hardcoding them in the header?

    • Hi Dimm. Thanks for mentioning the function name generation. I can reproduce what you’re saying, but this is actually by design so that function names do not get too long. If necessary, the function name generation trims the “filename” portion of the URL to the *final* 10 characters. This is so that you can see the file extension. There might be more graceful ways to handle it besides just increasing the limit or showing just the first 10 characters, so I’m open to suggestions.

      Also, thanks for your suggestion about preserving cookies between subsequent requests based on the previous response. I’ve had a number of requests to improve cookie handling, so I may look into this. It’s just a matter of how much it would complicate the generated code as well as how this would be enabled or disabled in the UI, as space is at a premium. Again, suggestions are welcome.


  19. Hello!
    Firstly I would like to thank you for the great extension!
    It works great, even the multipart-b req are working fine.
    But in my opionion it would be cool if u could add option to automatically decode the response body. I mean :

    using (var httpWebResponse = imgrequest.GetResponse() as HttpWebResponse)
    Stream stream = null;
    using (stream = httpWebResponse.GetResponseStream())
    if (httpWebResponse.ContentEncoding.ToLower().Contains(“gzip”))
    stream = new GZipStream(stream, CompressionMode.Decompress);
    else if (httpWebResponse.ContentEncoding.ToLower().Contains(“deflate”))
    stream = new DeflateStream(stream, CompressionMode.Decompress);

    var streamReader = new StreamReader(stream, Encoding.UTF8);
    strResponse = streamReader.ReadToEnd() ;

    What do you think about it ?

    • Hi Piotr. Thanks for the good idea. I will look into this and likely add it in the next release. It would probably be another optional check like the “Comments” and “Usage” so that it doesn’t always bulk up the generated code. Thanks for your suggestion!

    • Hi Piotr. Request to Code version has just been released and adds support for response reading. Thank you again for your suggestion. ~Chad

  20. Nice plugin. Could be very useful, but I have one slight problem with it. When the request contains headers with quotes the resulting c# code is invalid. Example:

    request.Headers.Set(HttpRequestHeader.Authorization, “Digest realm=”Digest Authentication”, nonce=”nonce”, opaque=”opaque”, stale=”false”, algorithm=”MD5″, qop=”auth”, response=”51666f8aaef4d9eb290d441cf00b156c”, uri=”http://localhost.fiddler:63990/1/api/calls/4d148495-1310-4b89-b2c8-4d0c6cc90073/entries”, username=”ivar””);

    • Thanks! While most all headers were properly being set and escaped if needed, the HTTP Authorization header was not. This will be fixed in an upcoming release that you can expect within the next week.

  21. Is it possible to contribute to the plugin i.e. is it open source ?

Leave a Reply

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