(l = 1; 
x1 = 
          l*Sin[φ1[t]]; 
x2 = 
          x1 + l*Sin[φ2[t]]; 
y1 = 
          l*Cos[φ1[t]]; 
y2 = 
          y1 + l*Cos[φ2[t]];)

(x1p = D[x1, t];  
        x2p = D[x2, t]; 
y1p = D[y1, t];  
        y2p = D[y2, t];)

L = (1/2)*(m1*(x1p^2 + y1p^2) + 
                  m2*(x2p^2 + y2p^2)) + 
            grav*(m1*y1 + m2*y2);

(Gleichung1=D[D[L,(φ1)'[t]],t]==D[L, φ1[t]]//Simplify;
Gleichung2=D[D[L,(φ2)'[t]],t]==D[L, φ2[t]]//Simplify;)

Lsgn=Solve[{Gleichung1, Gleichung2},{(φ1)''[t],(φ2)''[t]}]//Flatten;

(φ1)'[t]=omega1; (φ2)'[t]=omega2;φ1[t] = phi1; φ2[t] = phi2;

(force1=Lsgn[[1, 2]] // Expand // Simplify // 
              InputForm;
\(StringReplace[
            ToString[
              force1], {"Sin[" -> "Math.sin(", "Cos[" -> "Math.cos(", "]" -> ")"
, "omega1^2" -> "omega1*omega1", "omega2^2" -> "omega2*omega2"}]\))

(force2=Lsgn[[2, 2]] // Expand // Simplify // 
              InputForm;
\(StringReplace[
            ToString[
              force2], {"Sin[" -> "Math.sin(", "Cos[" -> "Math.cos(", "]" -> ")"
, "omega1^2" -> "omega1*omega1", "omega2^2" -> "omega2*omega2"}]\))

(\(Energy = \(\((1/2)\)*\((m1*\((x1p^2 + y1p^2)\) + 
                      m2*\((x2p^2 + y2p^2)\))\) - grav*\((m1*y1 + m2*y2)\) // 
              FullSimplify\) // InputForm; 
StringReplace[
          ToString[
            Energy], {"Sin[" -> "Math.sin(", "Cos[" -> "Math.cos(", "]" -> ")"
, "omega1^2" -> "omega1*omega1", "omega2^2" -> "omega2*omega2"}]\))