How to Open an S2P (Touchstone) File: 6 Ways and a Free Viewer

An S2P file is a plain-text Touchstone file holding the two-port S-parameters of a device at many frequencies. You can plot it right here in your browser (the file never leaves your computer), read it in a text editor, or open it in RF View, Python, MATLAB or a spreadsheet.

For practitioners

Open it right here

Drop your file into the viewer below, or load one of the three sample files to see how it works. The file is read in your browser and is not uploaded anywhere.

Drop an S-parameter file here (.s1p, .s2p, .s3p, .s4p …) or

The file is read in your browser. It is not uploaded anywhere.

No file at hand? Try a sample: · ·

You can also download the samples and open them with any of the other methods in this guide: 3rd-order low-pass filter, series-LC notch trap and 10 dB attenuator. They are generated from ideal circuit models, so they contain no measured or proprietary data, and each one uses a different number format (explained next).

Devicefilter, amplifier, cablePort 1Port 2S21: what gets through, port 1 to port 2S12: what gets through the other wayS11 (echo)S22 (echo)First number = where the wave comes out, second = where it went in.
A two-port device and its four S-parameters. Concept drawing.

What is inside an S2P file

An S2P file is the Touchstone description of a two-port device: a filter, an amplifier, a cable, a switch or an antenna with a feed. It lists the scattering parameters (S-parameters) of the device at a series of frequencies. Because it is plain text you can read it in any editor. This is the start of the low-pass filter sample above:

! 3rd-order Butterworth low-pass filter, 1 GHz cutoff (lossless).
# GHz S MA R 50
! freq  S11  S21  S12  S22
0.0500 0.000125 84.268 1.000000 -5.732 1.000000 -5.732 0.000125 84.268
0.0750 0.000422 81.398 1.000000 -8.602 1.000000 -8.602 0.000422 81.398
0.1000 0.001000 78.522 1.000000 -11.478 1.000000 -11.478 0.001000 78.522

Three kinds of lines appear:

  • Comment lines start with an exclamation mark (!). A comment can also follow data on the same line. Programs ignore them, but they often say what was measured.
  • The option line starts with # and appears once, before the data. It says how to read the numbers: # GHz S MA R 50 means frequencies in gigahertz, S-parameters, magnitude-and-angle format, 50 Ω reference impedance. The fields can come in any order and are not case-sensitive. If a field is missing, the defaults are GHz, S, MA and 50 Ω.
  • Data lines carry one frequency each. The first number is the frequency and the rest are the S-parameters at that frequency.

The option line

FieldAllowed valuesDefault
Frequency unitHz, kHz, MHz, GHzGHz
Parameter typeS (scattering), Y, Z, H, GS
Number formatRI, MA, DBMA
Reference resistanceR followed by a value in ohmsR 50

The three number formats

Every S-parameter is a complex number, so each one takes two columns. The three formats are different ways to write the same number:

FormatColumn 1Column 2Convert to a complex number
RIreal partimaginary partS = a + jb
MAlinear magnitudeangle in degreesS = a · (cos b + j sin b)
DBmagnitude in dBangle in degreesS = 10^(a/20) · (cos b + j sin b)

In the first data line above, S11 is 0.000125 at an angle of 84.268°, which is a magnitude of 20·log10(0.000125) = −78 dB: the filter is almost perfectly matched at 50 MHz. S21 is 1.000000 at −5.732°, which is 0 dB of transmission with a small phase delay.

The order of the columns

For a two-port file the order on each data line is fixed: S11, S21, S12, S22. Note that S21 comes before S12, which is the opposite of what many people expect from reading the matrix row by row. The 2-port order is a special case in the Touchstone format.

For files with three or more ports the data is written as the matrix row by row: S11, S12, S13 and so on, then S21, S22, S23. Each row starts a new line, a row never carries more than four value pairs per line, and only the first line of a frequency starts with the frequency itself. A four-port (.s4p) file therefore has four lines per frequency.

This is a frequent source of mistakes: code written for two-port files and reused for four-port files reads the wrong columns, and the results look plausible but are wrong. For the port conventions in more detail, see the RF View glossary on port numbering in SNP files.

# GHz S MA R 50 (option line: GHz, S-parameters, size and angle, 50 ohm)1.0000.0502-170.30.9975-3.80.9975-3.80.0502-170.3frequencyin GHzS11size, angleS21size, angleS12size, angleS22size, angleOne line = one frequency. Size 0.9975 means almost everything passes.
How to read one line of an S2P file (MA format).

Six ways to open an S2P file

1. In your browser

The viewer at the top of this page plots magnitude, phase, VSWR, group delay and a Smith chart, shows the values at the cursor and exports the traces to CSV. It reads one-port to four-port Touchstone files in all three number formats, in Hz to GHz, and skips noise data. It is a quick way to look at a file on any computer without installing anything. It is not a replacement for a full analysis tool: it does not de-embed, compare several files or apply markers that you can save.

2. In a text editor

Notepad, VS Code, Notepad++ or any editor will do. Use it to check the option line, find the units and see whether the file is complete. Do not edit the data by hand unless you know what you are doing, and make sure the file keeps the .s2p extension and plain-text encoding when you save it.

3. In RF View

RF View, the app behind this website, opens .s1p to .s4p files on Windows and Android and plots dB, VSWR, phase, group delay and a Smith chart, with markers and a SNP converter. The basic version is free. See the download page and the pricing page for what is free and what is in Pro. Disclosure: RF View is our own product.

4. In Python with scikit-rf

scikit-rf is an open-source Python package for RF work and reads Touchstone files directly:

import skrf as rf
import matplotlib.pyplot as plt

net = rf.Network("lowpass-3rd-order.s2p")   # downloaded sample
print(net)                                   # number of ports, frequency range, points
net.plot_s_db()                              # all four S-parameters in dB
print(net.f[:3])                             # first frequencies, in Hz
print(net.s_db[:3, 1, 0])                    # S21 in dB at those frequencies
plt.show()

Note the indexing: net.s_db[:, 1, 0] is S21 (row 2, column 1). scikit-rf converts every file to the same internal layout, so you do not have to care about the special two-port column order.

5. In MATLAB

MATLAB with the RF Toolbox reads Touchstone files with the sparameters function, and plots them with the RF Toolbox plotting functions. Check the toolbox documentation of your release for the exact calls, because the function signatures have changed between releases.

6. In a spreadsheet

Excel and Google Sheets can import the file as text with a space as the delimiter, but remove the comment lines and the option line first, because they are not data. The columns are then the frequency followed by the value pairs, so RI and MA data are not directly plottable in dB. The CSV export of the viewer above is easier: it writes the frequency in hertz and the magnitude in dB and the phase in degrees for each trace you select.

Most RF simulators and VNA programs can import Touchstone files as well, usually through an import or data-file option. Read the manual of your tool for the exact steps.

Common problems and how to fix them

The extension does not match the data. The number in .s2p is the number of ports, but some programs trust it and some read the data. If a four-port file is saved as .s2p, the result is garbage in one tool and correct in another. The viewer on this page reads the number of ports from the data and tells you if the file name says something else.

The frequencies are off by a factor of 1000. The option line sets the unit. A tool that ignores it, or a file whose option line is missing or damaged, shows kilohertz as megahertz or megahertz as gigahertz. If the option line is missing, the defaults GHz, S, MA and 50 Ω apply, and a viewer should warn you about that.

S12 and S21 are swapped. In a two-port file the order is S11, S21, S12, S22. Reading it as S11, S12, S21, S22 swaps the transmission and the isolation. For an amplifier the gain and the reverse isolation then change places, which is easy to spot (an amplifier with 20 dB of reverse gain is a clear sign), but for a passive reciprocal device (S12 = S21) the mistake is invisible. Touchstone 2.0 files can declare the order explicitly.

The reference impedance is not 50 Ω. The option line may say R 75 or another value. S-parameters measured in a 75 Ω system cannot be compared directly with 50 Ω data. Renormalize the file before comparing or cascading.

The frequencies do not increase. A file whose frequencies go back down, or repeat, is broken, or two sweeps have been joined. Many tools refuse it, and so does the viewer, with the line number in the message.

The file ends with extra data. A two-port file may contain noise parameters after the S-parameters: frequency, minimum noise figure, optimum source reflection coefficient and a normalized noise resistance. The viewer detects and skips them.

A passive device shows gain. If the largest singular value of the S matrix is above 1 for a device that cannot amplify, check the number format (DB versus MA), the sign of the dB values and the units. Measurement noise can push a good device slightly above 1, so a tiny excess is not a problem. The viewer reports it for one- and two-port files.

Touchstone 2.0. Version 2.0 adds keywords in square brackets ([Version] 2.0, [Number of Ports], [Network Data] and more) for per-port reference impedances, explicit data order, noise data and mixed-mode parameters. The viewer on this page reads the common subset (full matrices, the two-port order keyword, the reference keyword) and tells you clearly when a file uses something it cannot read, such as mixed-mode data or triangular matrices.

0-10-20-30-4000.511.522.53cutoff 1 GHz: -3 dBS21 (what passes)S11 (what bounces back)Frequency (GHz)dB
S21 and S11 of the low-pass sample filter, computed from the circuit model. Not measured data.

Quick checks after you open a file

A file can load without errors and still be wrong. A few quick checks catch most problems:

  1. Is the frequency range what you expect? Compare the start and stop frequency with the measurement setup.
  2. Is the device passive? Magnitudes above 0 dB for a passive device are suspicious. For a lossless two-port, |S11|² + |S21|² should equal 1; for a lossy one the sum is below 1.
  3. Is it reciprocal? For a passive device without ferrites or active parts, S12 and S21 should be the same. A large difference points to swapped columns or a measurement problem.
  4. Is the phase continuous? A smooth phase curve with steady slope is normal. Sudden jumps of 360° are just wrapping; jumps of other sizes are measurement errors or missing points.
  5. Does the return loss look believable? The VSWR and return loss calculator turns the S11 values you read into VSWR, mismatch loss and delivered power.

If you built the sample attenuator in your own circuit and measured it, the viewer would show S21 at −10 dB flat across the band; the attenuator calculator gives the resistor values that produce exactly that file.

In plain words · for students and beginners

S2P files in plain words

A device as a box with two connectors

Take any RF part with an input and an output: a filter, an amplifier, a cable. Think of it as a box with two connectors, called ports. S-parameters describe what the box does with a signal. S11 is the part of the signal that comes back out of port 1, the reflection. S21 is the part that gets through to port 2, the transmission. S12 and S22 are the same questions asked from the other side.

What the file is

An S2P file is a table of those four values for many frequencies, like a spreadsheet of how the box behaves from low to high frequency. Each row starts with a frequency and then lists the values. Because a signal has both a size and a timing, every value takes two numbers: a magnitude and an angle (or a real and an imaginary part, which is the same thing written differently).

Reading one line

Take the first lines of the low-pass sample on this page. At 50 MHz, S21 is about 0 dB: the signal passes almost unchanged. S11 is about -78 dB: practically nothing bounces back. At 1 GHz both are -3 dB, which means half of the power gets through and half is reflected. That is the edge of the filter, where it starts to block the signal.

Why the column order looks odd

In a two-port file the order is S11, S21, S12, S22. It feels backwards, but it is simply the rule of the format for two ports. If you read the columns by hand, remember it, or let a viewer do the reading.

Your first steps

  1. Drop the file into the viewer above, or load one of the samples.
  2. Look at S21 to see what passes and S11 to see what is reflected.
  3. Move the cursor along the plot to read the values at a frequency.
  4. If something looks wrong, check the unit and the format in the option line that starts with a hash sign.

Mistakes beginners make

  • Reading the frequency in the wrong unit. The option line says whether it is Hz, MHz or GHz.
  • Mixing up S12 and S21 because of the column order.
  • Trusting the extension. A file named .s2p can hold a different number of ports, so check the data.

Remember

  • S11 is what is reflected, S21 is what passes through.
  • Every value is two numbers: a size and an angle.
  • A plot shows you in seconds what the table hides.

Files and formats

Tools

Frequently asked questions

Can I open an S2P file in Notepad?

Yes. An S2P file is plain text, so any text editor shows its contents. That is useful for checking the option line (units, format, reference impedance) and the numbers, but a text editor cannot plot them. Use a viewer or an RF tool for plots.

What does the number in .s2p, .s1p or .s4p mean?

It is the number of ports of the device. An .s1p file describes a one-port (for example an antenna or a load), an .s2p file a two-port (a filter, an amplifier, a cable), and an .s4p file a four-port. The extension should match the data, but the data inside decides how the file is read.

Why do the frequencies in my file look 1000 times too large or too small?

The unit is set in the option line that starts with #. A file with # MHz holds frequencies in megahertz, and a file with # GHz in gigahertz. If a program ignores or misreads that line, every frequency is off by a factor of 1000. Check the option line first.

Is it safe to open a measurement file in the online viewer?

The viewer on this page reads the file inside your browser. It does not upload the file to any server, so the data stays on your computer. Do not paste confidential data into any online tool whose behaviour you cannot check, and prefer an offline tool for sensitive measurements.

What is the difference between S2P and S1P files?

An S1P file holds one reflection coefficient (S11) per frequency, the description of a one-port. An S2P file holds four values per frequency (S11, S21, S12, S22) for a two-port, so it also carries the transmission and the isolation between the ports.

References and further reading