I thought this should be a duplicate of Is there an advantage in using the pgf Basic Layer over tikz? but since there are a few tiny differences here is a very rough one just to archive this.
If you think of the code conversion as a mathematical function that recevies the PGF code and spits out TikZ code (I don't know why you would do that), it's a multivalued and nonsurjective function.
In other words, the same PGF snippet might lead to the different TikZ code. Example,
\begin{tikzpicture}
\pgfpathmoveto{\pgfpoint{2cm}{0cm}}
\pgfpathlineto{\pgfpoint{0cm}{2cm}}
{
\pgfinterruptpath
\color{red}
%\pgfsetstrokecolor{red}
\pgftransformshift{\pgfpoint{1.5cm}{1cm}}
\pgfnode{circle}{center}{A}{a}{\pgfqstroke}
\endpgfinterruptpath
}
\pgfpathlineto{\pgfpoint{-2cm}{0cm}}
\pgfclosepath
\pgfqstroke
\draw (0,0) -- (2,0) -- node[pos=0.4,above= 2mm,right=0.5mm] {A} (0,2) -- (-2,0) -- cycle;
\draw (0,0) -- (2,0) -- node[pos=0.38,anchor=south west] {A} (0,2) -- (-2,0) -- cycle;
\draw (0,0) -- (2,0) node at (1.5cm,1cm) {A} -- (0,2) -- (-2,0) -- cycle;
\end{tikzpicture}
(I'm approximating the equivalence of the commands) Let's say for some reason I've ended up with the PGF code above and I want to convert it to TikZ. However I have no idea why the node is inserted in between. If it was coming from a TikZ like code where you have node[midway] I should have some interpolation etc. But this is bluntly inserted.
I can try to convert via the options given above (and many more) but why should I prefer one to another? Well in this example it is obvious that the last one is the most sane one but others are trying to get [pos=x] syntax.
Even worse, TikZ code keeps the settings such as current line width, color etc. local to the object but in PGF code it comes one another as macros. It is almost always a problem that a setting leaks out to whatever that follows until the setting is reset again. For example, remove all the TikZ based drawing commands and check the output. Comment \color{red} and remove the comment from the next line. WTF? It's always fun.
That's why any interpreter would then resort back to primitive building blocks (you can have a look at InkScape2TikZ output, I think it's doing a great job by the way)
\draw (a) -- (b);
\draw (b) -- (c);
\path node at (d) {A};
Even this will not assure that we actually close the path. So nodes should come later if we have a closed path and the adventure begins :)
Second issue is that not every PGF command can be reproducible via TikZ syntax. But that's kind of known and is a subject of many questions including the linked one anyway.
pgfcode directly in a TikZ environment. – Jake May 12 '13 at 15:46matlab2tikzwhich is often mentioned on TeX.sx produces TikZ output. Then there isinkscape2tikz. Check http://www.texample.net/tikz/examples/tag/code-generation/ for other examples generated by other software.dot2texcan generate PSTricks as well as PGF and TikZ code. To answer your question: Yes, it is possible to convert PGF to TikZ code (by hand at least) but with an overhead, as TikZ does and is more than just PGF. Your request is very exceptional because for most people it is easier to write TikZ code than it is to write PGF code. – Qrrbrbirlbel Jun 25 '13 at 21:14